我正在使用应用程序包 - 我的 android 应用程序的动态功能模块。我遵循了文档并实施了所有必需的步骤,
(1) Used PlayCore Library - version 1.3.7
(2) Used the SplitCompat Library in my Application class (attachBaseContext)
(3) Used the SplitCompat.install(context) in attachBaseContext() of the new modules launching actvity
(4) Implemented and initiated the SplitInstallManager instance and handled the error codes and status updates.
(5) Double checked the build.gradle and manifest files and everything looks perfect.
我从 android studio 启动了应用程序,将部署选项设置为“来自应用程序包的 Apk”
但是当我单击按钮安装模块时,应用程序崩溃了。
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.something.myapp/com.something.myapp.sample_module.activity.SampleActivity}: java.lang.ClassNotFoundException: Didn't find class "com.something.myapp.sample_module.activity.SampleActivity" on path: DexPathList[[zip file "/data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/base.apk", zip file "/data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.arm64_v8a.apk", zip file "/data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.en.apk", zip file "/data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.si.apk", zip file "/data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/lib/arm64, /data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/base.apk!/lib/arm64-v8a, /data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.en.apk!/lib/arm64-v8a, /data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.si.apk!/lib/arm64-v8a, /data/app/com.something.myapp-OYWwJYvG4hSEq9ul1Y6rHA==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2881)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
它说无法实例化活动。此应用程序使用 MultiDex 功能,但我认为它不会影响应用程序包 - 动态模块。
当我调试应用程序时,它会进入 SplitInstallSessionStatus.INSTALLED 状态,然后它会启动下载模块的活动。然后它崩溃了。
更新:这是动态模块中的 AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.something.myapp.sample_module">
<dist:module
dist:instant="false"
dist:onDemand="true"
dist:title="@string/module_sample">
<dist:fusing dist:include="true" />
</dist:module>
<application android:allowBackup="true">
<activity android:name="com.something.myapp.sample_module.activity.SampleActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</application>
</manifest>
这是 SplitInstallService 的另一个日志:
SplitInstallService : startInstall([sample_module],[])
SplitInstallService : Initiate binding to the service.
com.google.android.finsky.splitinstallservice.du.a(10): Connecting InstallListener to SplitInstallService broadcaster...
SplitInstallService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.splitinstallservice.SplitInstallService})
SplitInstallService : linkToDeath
SplitInstallService : Unbind from service.
SplitInstallService : onStartInstall(0)
那么如何解决这个问题呢?任何建议表示赞赏。
谢谢