【问题标题】:App Bundle: Can Application class be in a Dynamic Feature module? App bundle crashesApp Bundle:应用程序类可以在动态功能模块中吗?应用程序包崩溃
【发布时间】:2020-01-08 23:48:07
【问题描述】:

在为 App Bundle 重构代码时,自定义 Application 类是否可以保留在 com.android.dynamic-feature 模块中,还是应该只在 com.android.application 基本模块中?

我看到基础的合并清单具有自定义应用程序类,但是当我启动应用程序时,我在无限循环中看到下面的错误消息。模拟器最终崩溃。

具有intent.action.MAIN and LAUNCHER 的LaunchActivity 也应该在com.android.application 模块中,还是可以在com.android.dynamic-feature 模块中?

2020-01-08 15:45:16.134 ? E/<apppackage>: Unknown bits set in runtime_flags: 0x8000
2020-01-08 15:45:16.136 ? W/<apppackage>: Unexpected CPU variant for X86 using defaults: x86

2020-01-08 15:45:16.663 ? I/lowmemorykiller: Suppressed 83 failed kill reports

2020-01-08 15:45:16.781 ? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 923592)
2020-01-08 15:45:16.786 ? E/ActivityManager: Exception thrown during bind of ProcessRecord{a6f5e75 13002:<apppackage>/u0a166}
    android.os.TransactionTooLargeException: data parcel size 923592 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:510)
        at android.app.IApplicationThread$Stub$Proxy.bindApplication(IApplicationThread.java:1479)
        at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:5058)
        at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:5180)
        at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2003)
        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2741)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)

【问题讨论】:

  • 按照我的回答找到解决方法了吗?

标签: android android-app-bundle app-bundle dynamic-feature-module


【解决方案1】:

动态功能模块的应用程序类将保留在自身内部..

每当您下载该模块时,它都会下载该模块内的所有资源,之后两者的 androidManifest.xml 文件:基本应用程序模块和动态模块将被合并...这仅在使用 aab 实现时有用( Android 应用程序包)。

此外,无论您在何处扩展应用程序类...您都必须实现一种覆盖方法,如下所示...

override fun attachBaseContext(base: Context) {
        super.attachBaseContext(base)
        SplitCompat.install(this)
    }

确保您在动态功能模块中没有任何启动器活动(因为它会在手机上创建另一个看起来不合适的应用程序图标)。
我之前遇到过这个问题,它对我有用……我希望你能找到解决方案。 :)

【讨论】:

  • 这是否意味着您在动态功能模块中拥有自定义应用程序而不是 com.android.application 模块?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-23
  • 1970-01-01
  • 2019-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多