I am working on the dynamic feature module. I uploaded the .aab file into playstore some times app is unable to open the module throwing the error like this.
This is the error getting in logcat:
PID: 12715
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.testDynamic/com.testDynamic.zco.ZcoActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.testDynamic.zco.ZcoActivity"
on path: DexPathList[[zip file
"/data/app/com.testDynamic-1/base.apk",
This issue here is my code.
This is my Main app manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.testDynamic">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<dist:module dist:instant="true" />
<application
android:name=".Application"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is my module Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.testDynamic.zco"
split="dynamiczco">
<dist:module
dist:onDemand="true"
dist:title="@string/title_test">
<dist:fusing dist:include="true" />
</dist:module>
<application>
<activity
android:name="com.testDynamic.module.ZcoActivity"
android:label="@string/title_activity_test"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>
</manifest>
Here is my main gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.testDynamic"
minSdkVersion 23
targetSdkVersion 27
versionCode 33
versionName "3.1"
}
dynamicFeatures = [":dynamicmodule",":dynamic_feature2",":dynamiczco"]
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api 'com.android.support:appcompat-v7:27.1.1'
api 'com.android.support:recyclerview-v7:27.1.1'
api 'com.google.android.play:core:1.3.1'
api 'com.android.support.constraint:constraint-layout:1.1.2'
api 'com.squareup.retrofit2:retrofit:2.1.0'
api 'com.squareup.retrofit2:converter-gson:2.1.0'
api 'com.android.support:cardview-v7:27.1.1'
}
Here is my module gradle:
apply plugin: 'com.android.dynamic-feature'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 20
targetSdkVersion 27
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':app')
// implementation 'com.google.android.material:material:27.0.+'
}
Anyone have an idea about this error please help me to resolve
Anyone help to solve this issue. Thanks in advance.
Hi after researching i got the solution. Now the module was downloading without any crash.
I changed the module manifest
<dist:module
dist:onDemand="true"
dist:title="@string/title_test">
<dist:fusing dist:include="true" />
to
<dist:module
dist:instant="true"
dist:onDemand="false"
dist:title="@string/title_test">
<dist:fusing dist:include="true" />
</dist:module>
It is working fine. Thank you all