简体   繁体   中英

App Bundle: Can Application class be in a Dynamic Feature module? App bundle crashes

While refactoring your code for App Bundles, can the custom Application class remain in the com.android.dynamic-feature module or should it be only in the com.android.application base module?

I see the base's merged manifest having the custom Application class, but when I start the app, I see the error message below in an infinite loop. Emulator ultimately crashes.

Should the LaunchActivity which has the intent.action.MAIN and LAUNCHER also be in the com.android.application module, or can it be in the com.android.dynamic-feature module?

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)

The application class of dynamic feature module will remain inside of itself..

whenever you will download that module, it will download all the resources inside of that module, and after that androidManifest.xml files of both: base app module and the dynamic module will be merged...This is only useful while implementing with aab (Android App Bundle).

also, you wherever you extend application class...you must implement one override method as below...

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

make sure you don't have any launcher activity in dynamic feature module (because it will create another app icon on the phone which doesn't look appropriate).
I have faced this earlier and It works for me...I hope you will have your solution. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM