I maintain an Android product where I've modularized several components into dynamic features. During the final packaging stage, I use packageReleaseUniversalApk to bundle all modules into a single APK, which is then published on Google Play. However, when I monitor error logs from users, I occasionally encounter reports of ActivityNotFoundException when users attempt to launch activities from dynamic features. I haven't been able to replicate this issue on my machine or those of my colleagues. I believe it's not a widespread problem. How should I go about resolving this issue?
the AndroidManifest setting of app
<dist:module dist:instant="false" />
the Dynamic Feature Module AndroidManifest Setting.
`
<dist:module
dist:instant="false"
dist:title="@string/xxxx">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
<application>
<activity android:name=".XXXXActivity"/>
</application>
`
I have no idea what went wrong , can anyone please help to give an suggestion on how to solving the issue?
I have no idea, cause this issue only occur on quite a few devices of my customer, I never reproduce the issue on my end. I wonder whether it is a multidex issue. But since my app targetSDK is 24 or higher, so I do not think I need to add multidex library in gradle.
the exception detail info is as below. Unable to find explicit activity class {us.video.test/us.video.test.submodule.XXXXActivity}; have you declared this activity in your AndroidManifest.xml?
the way I start the dynamic module activity is as below.
val splitInstallManager =
SplitInstallManagerFactory.create(GlobalVariable.applicationCtx)
if (splitInstallManager.installedModules.contains(moduleName)) {
val i = Intent()
i.setClassName(
us.video.test.BuildConfig.APPLICATION_ID,
"$modulePackageName.$activityName"
)
i.setPackage(modulePackageName)
i.putExtra(Constants.ARG_PROJECT_INFO, projectInfo?.toByteArray())
launcher?.let {
it.launch(i)
} ?: let {
context.startActivity(i)
}
}