3

done:

  1. generate a release a.abb
  2. use bundletool to convert a.abb to a.apks.
  3. deploy it to device.

problem:

the activity in dynamic feature no found.(but in debug, it's ok)

2019-02-25 20:48:58.429 11164-11164/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.demo.yang.myapplication, PID: 11164
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.demo.yang.myapplication/com.demo.yang.feature.TestActivity}: java.lang.ClassNotFoundException: Didn't find class "com.demo.yang.feature.TestActivity" on path: DexPathList[[zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/base.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.en.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.es.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ja.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ko.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.pt.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ru.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.vi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.xxhdpi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.zh.apk"],nativeLibraryDirectories=[/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/lib/arm64, /system/lib64, /vendor/lib64]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6938)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.demo.yang.feature.TestActivity" on path: DexPathList[[zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/base.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.en.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.es.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ja.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ko.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.pt.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ru.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.vi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.xxhdpi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.zh.apk"],nativeLibraryDirectories=[/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1180)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2829)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030) 
    at android.app.ActivityThread.-wrap11(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
    at android.os.Handler.dispatchMessage(Handler.java:105) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6938) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 
    Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.en.apk
    at dalvik.system.DexFile.openDexFileNative(Native Method)
    at dalvik.system.DexFile.openDexFile(DexFile.java:353)
    at dalvik.system.DexFile.<init>(DexFile.java:100)
    at dalvik.system.DexFile.<init>(DexFile.java:74)
Community
  • 1
  • 1

5 Answers5

2

The fact that the class is found in debug but not in release suggests that it's possibly an issue with your proguard configuration (since Proguard is usually applied only on release builds).

Make sure you have

-keep public class * extends android.app.Activity

in your proguard file to ensure that the Activities are not obfuscated.

Pierre
  • 15,865
  • 4
  • 36
  • 50
  • This should be unnecessary, Activities defined in the AndroidManifest should be automatically excluded from ProGuard. check [this](https://stackoverflow.com/a/19192262/2708768) and [this](https://stackoverflow.com/a/36563007/2708768) – Mustafa Berkay Mutlu Apr 19 '19 at 10:04
  • Proguard is not an Android specific tool. Android Studio just happens to provide a good default proguard spec for Android apps but OP didn't mention if they use Studio, nor whether they have changed the default proguard spec. – Pierre Apr 19 '19 at 17:37
1

Please add this to your build.gradle at dynamic feature you create.

apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions'

dagung
  • 96
  • 1
  • 4
0

What worked for me was: remove all the tags <application> from the dynamic features' AndroidManifest and reunite all the Activities declarations on the application's AndroidManifest.

And before that I follow these migrations steps

0

I faced and fixed this issue. This problem arises, when you are not setting multiDexEnabled option correctly in your base build.gradle (app level) & the project itself.

defaultConfig {
    ...
    multiDexEnabled true
}

And in dependencies

dependencies{
    ....
    
    implementation "androidx.multidex:multidex:$multidex_version"
    
    }

And you can extend your application class from MultiDexApplication

class YOUR_APPLICATION_CLASS : MultiDexApplication() {

// Rest of your code

}

In base app Manifest mention above application class like:

<application
        android:name=".YOUR_APPLICATION_CLASS"
    ...
</application>

I paste less code for brevity.

Shihab Uddin
  • 6,699
  • 2
  • 59
  • 74
0

what it is step 3?

bundletool install-apks --apks=/MyApp/my_app.apks

its not correct. I suggest you do this:

  1. unzip your APKs file.
  2. Select the apks you want to install
adb install-multiple xxx-1.apk xxx-2.apk xxx-3.apk

Pls refer this

zeng
  • 1
  • 1