1
 Intent intent=new Intent(MainActivity.this, ContactListActivity.class);
                        startActivity(intent);

MainActivity.this is written in java and ContactListActivity is written in kotlin. I am trying to call the ContactListActivty but end up getting the error

 have you declared this activity in your AndroidManifest.xml?

I have also added the activity in the manifest file.

 <activity android:name="Chat_Activity$Connections$ContactListActivity"
            android:parentActivityName=".MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity"/>
        </activity>

EDIT:

ContactListActivity.kt

class ContactListActivity : AppCompatActivity() {

    private var mBroadcastReceiver: BroadcastReceiver? = null
    private val TAG:String="ContactListActivity"

    //static variable
    object Obz{
        @JvmStatic val GetContactListFromServer:String="Contact List"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(layout.activity_contact_list)


        title = "Contact list"

        contact_list.hasFixedSize()
        contact_list.layoutManager= LinearLayoutManager(this)

        getContactListAndNextActivity()
    }

    fun getContactListAndNextActivity(){

        contact_list.adapter= ContactListAdaptor(applicationContext, dbHelper(applicationContext).getContactList())

    }

}
Ankur Khandelwal
  • 269
  • 1
  • 4
  • 17

2 Answers2

0

Your manifest name entry looks suspect.

android:name="Chat_Activity$Connections$ContactListActivity"

I'm not sure what the fully qualified path name is, but try:

android:name=".ContactListActivity"

or

android:name="<qualified.path.to>.ContactListActivity"

Tim Malseed
  • 6,003
  • 6
  • 48
  • 66
  • @AnkurKhandelwal what did you try? You need to be more specific. – Tim Malseed May 08 '17 at 11:50
  • Also, was the app compiling other Kotlin code before you added this Activity? Perhaps you haven't configured Kotlin correctly in your project yet? – Tim Malseed May 08 '17 at 11:51
  • I have tried your answer. i.e. replace the manifest class name android:name="Chat_Activity$Connections$ContactListActivity" to android:name=".ContactListActivity" – Ankur Khandelwal May 08 '17 at 11:52
  • Did you try the 'fully qualified name' as well? – Tim Malseed May 08 '17 at 11:52
  • I have configured the kotlin in the same way as I have configured it in the other project – Ankur Khandelwal May 08 '17 at 11:53
  • yes. Chat_Activity$Connections is the fully qualified name. right? – Ankur Khandelwal May 08 '17 at 11:54
  • I don't know, you haven't provided your package structure. It shouldn't have a '$' in it, and I'm surprised to see an underscore as well. – Tim Malseed May 08 '17 at 11:56
  • Ok. This time I have removed the capital starting char and make it small in the package name. But got error `Error:Execution failed for task ':app:compileDebugKotlin'`. To remove this, I have tried the "Invalidate caches/Restart and clean options" – Ankur Khandelwal May 08 '17 at 12:24
  • I have given the package name with starting the capital letters and given the _ in between the package name/folder. – Ankur Khandelwal May 08 '17 at 12:40
  • Ok, sounds like you've solved your initial problem and now you have a new one. You should consider asking a new question and provide the relevant details. – Tim Malseed May 08 '17 at 23:32
0

I had similar problem, Try to rename Your activity add 1 symbol for ex: and inside your manifest write

android:name=".ContactListActivity1"

after that you can rename again and set it old name

Jemo Mgebrishvili
  • 5,187
  • 7
  • 38
  • 63