1

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.videomodule/com.myapp.videomodule.VideoCallActivity}; have you declared this activity in your AndroidManifest.xml?

My app package is com.myapp.doctors module package is com.myapp.videomodule

if(splitInstallManager.getInstalledModules().contains("videomodule")){
Intent intent = new Intent(); 
intent.setClassName("com.myapp.videomodule", "com.myapp.videomodule.VideoCallActivity");
startActivity(intent); 
}

I have declared it in the manifest the thing is I am trying dymanic module delivery, so that videoactivity is in other module

savvisingh
  • 93
  • 7
  • 2
    Possible duplicate of [android.content.ActivityNotFoundException:](https://stackoverflow.com/questions/3433778/android-content-activitynotfoundexception) – Abhishek Jun 06 '18 at 15:38
  • savvisingh's question is related to dynamic features, in his case he will not have reference to the activity they want to start. Therefore not related to the issue you linked Abhiskek. They need to start the activity by name, however even so they are getting that error. I am actually facing the same issue even after: `if(splitInstallManager.getInstalledModules().contains("mymodule"))` succeeds. :( – Matt Carron 52 secs ago Edit Delete – Matt Carron Nov 20 '19 at 13:52
  • I faced this issue and I believe ran into the same mistake. Nico's answer was correct for me and likely for this question too. I had the application package name and the activity's package name the same in my `setClassName` which was the issue. In my case my dynamic module had a different package name to the app module so to fix this I had something like this: `intent.setClassName("com.myapp.appmodule", "com.myapp.videomodule.VideoCallActivity");` – Matt Carron Nov 20 '19 at 16:00

3 Answers3

2

It seems that dynamic feature modules are declared in base app package. (as you can verify using Merged Manifest feature on your module Manifest.xml

I suggest the following modification:

if(splitInstallManager.getInstalledModules().contains("videomodule")){
    Intent intent = new Intent(); 
    intent.setClassName(getPackageName(), "com.myapp.videomodule.VideoCallActivity");
    startActivity(intent); 
}
Nico
  • 2,570
  • 1
  • 9
  • 17
1

Go to manifests > AndroidManifest.xml > check if com.myapp.videomodule.VideoCallActivity is declared there, if not, put it like:

<manifest>

.... 

<application
        ...>

        ...

        <activity
            android:name="com.myapp.videomodule.VideoCallActivity"
            android:label="@string/title_videocallactivity" your activity title 
            android:theme="@style/AppTheme.NoActionBar" />

        ...
</application>

</manifest>
Rodrigo João Bertotti
  • 5,179
  • 2
  • 23
  • 34
  • 1
    I have declared it in the manifest the thing is I am trying dymanic module delivery, so that videoactivity is in other module – savvisingh Jun 07 '18 at 07:06
-1

Try starting the intent like this:

Intent intent = new Intent(this, VideoCallActivity.class);
startActivity(intent)
Drusantia
  • 327
  • 1
  • 8
  • This is the classic ways to start an activity, but the author is in dynamics feature context. – Crisic Apr 20 '20 at 08:43