1

假设我创建了一个 Android 项目AwesomeApp。然后我需要向这个应用程序添加聊天功能。因此,我创建了另一个项目来构建用于聊天的 SDK。我的聊天 SDK 的输出是 4 个aar文件。这些aar文件包含另一个聊天 SDK 的Applozic.

然后我成功地将 4 个aar文件集成到我的文件中AwesomeApp,一切正常。但是aar文件太大了。所以我决定使用Android新的动态交付功能。

为此,我创建了新项目。在清单文件中,我提到了这样的应用程序名称android:name="com.google.android.play.core.splitcompat.SplitCompatApplication"。在这个项目中,我创建了一个动态模块chat-module。在这个动态模块中,我创建了一个活动DynamicActivity并添加了这 4 个aar文件。DynamicActivity我通过单击一个图标来调用(aar 文件的)聊天功能。

我可以成功下载chat-module并打开动态模块DynamicActivitychat-module但是当我点击打开/初始化聊天功能的图标时DynamicActivity- 应用程序崩溃了。崩溃报告:

    java.lang.IllegalStateException: Could not execute method for android:onClick
        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
        at android.view.View.performClick(View.java:6304)
        at android.view.View$PerformClick.run(View.java:24803)
        at android.os.Handler.handleCallback(Handler.java:794)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:176)
        at android.app.ActivityThread.main(ActivityThread.java:6651)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
        at android.view.View.performClick(View.java:6304) 
        at android.view.View$PerformClick.run(View.java:24803) 
        at android.os.Handler.handleCallback(Handler.java:794) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:176) 
        at android.app.ActivityThread.main(ActivityThread.java:6651) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/applozic/mobicomkit/Applozic;
        at com.example.chatapp.utility.ChitChat.initialize(ChitChat.java:83)
        at com.example.chatapp_dynamic_module.DynamicActivity.startSecondPerson(DynamicActivity.java:53)
        at java.lang.reflect.Method.invoke(Native Method) 
        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) 
        at android.view.View.performClick(View.java:6304) 
        at android.view.View$PerformClick.run(View.java:24803) 
        at android.os.Handler.handleCallback(Handler.java:794) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:176) 
        at android.app.ActivityThread.main(ActivityThread.java:6651) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.applozic.mobicomkit.Applozic" on path: DexPathList[[zip file "/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/base.apk", zip file "/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.en.apk", zip file "/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.xhdpi.apk", zip file "/data/user/0/com.example.applab/files/splitcompat/1/verified-splits/chitchat_dynamic_module.apk"],nativeLibraryDirectories=[/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.example.chatapp.utility.ChitChat.initialize(ChitChat.java:83) 
        at com.example.chatapp_dynamic_module.DynamicActivity.startSecondPerson(DynamicActivity.java:53) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) 
        at android.view.View.performClick(View.java:6304) 
        at android.view.View$PerformClick.run(View.java:24803) 
        at android.os.Handler.handleCallback(Handler.java:794) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:176) 
        at android.app.ActivityThread.main(ActivityThread.java:6651) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/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)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
        at dalvik.system.DexPathList.<init>(DexPathList.java:157)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:695)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:729)
        at android.app.LoadedApk.getResources(LoadedApk.java:956)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2282)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
        at android.os.Handler.dispatchMessage(Handler.java:106)
                ... 5 more
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.xhdpi.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
2019-10-13 12:32:06.538 25730-25730/com.example.applab E/AndroidRuntime:     at dalvik.system.DexFile.openDexFile(DexFile.java:353)
        at dalvik.system.DexFile.<init>(DexFile.java:100)
        at dalvik.system.DexFile.<init>(DexFile.java:74)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
        at dalvik.system.DexPathList.<init>(DexPathList.java:157)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:695)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:729)
        at android.app.LoadedApk.getResources(LoadedApk.java:956)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2282)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
        at android.os.Handler.dispatchMessage(Handler.java:106)
                ... 5 more

请帮我解决问题。

4

0 回答 0