3

完毕:

  1. 生成一个版本 a.abb
  2. 使用 bundletool 将 a.abb 转换为 a.apks。
  3. 将其部署到设备。

问题:

找不到动态功能中的活动。(但在调试中,没关系)

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)
4

4 回答 4

2

在调试中找到该类但在发布中找不到该类的事实表明它可能是您的 proguard 配置的问题(因为 Proguard 通常仅应用于发布版本)。

确保你有

-keep public class * extends android.app.Activity

在您的 proguard 文件中,以确保活动没有被混淆。

于 2019-02-26T15:25:50.570 回答
1

请将此添加到您创建的动态功能的 build.gradle 中。

应用插件:'kotlin-android' 应用插件:'kotlin-android-extensions'

于 2020-03-02T10:35:46.213 回答
0

对我有用的是:<application>从动态功能的 AndroidManifest 中删除所有标签,并重新统一应用程序 AndroidManifest 上的所有活动声明。

在此之前,我遵循这些迁移步骤

于 2019-05-06T20:09:51.220 回答
0

我面对并解决了这个问题。当您没有在基础build.gradle(应用程序级别)和项目本身中正确设置multiDexEnabled选项时,就会出现此问题。

defaultConfig {
    ...
    multiDexEnabled true
}

依赖项中

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

您可以从MultiDexApplication扩展您的应用程序类

class YOUR_APPLICATION_CLASS : MultiDexApplication() {

// Rest of your code

}

基础应用清单中提到上述应用程序类,例如:

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

为简洁起见,我粘贴了较少的代码。

于 2020-07-15T12:43:26.137 回答