簡體   English   中英

App Bundle:應用程序類可以在動態功能模塊中嗎? 應用程序包崩潰

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

在為 App Bundle 重構您的代碼時,自定義 Application 類可以保留在com.android.dynamic-feature模塊中還是應該只在com.android.application基礎模塊中?

我看到 base 的合並清單具有自定義 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)

動態功能模塊的應用程序類將保留在其內部。

每當您下載該模塊時,它都會下載該模塊內的所有資源,然后兩者的 androidManifest.xml 文件:基本應用程序模塊和動態模塊將被合並......這僅在使用 aab 實現時有用( Android 應用程序包)。

此外,無論您在何處擴展應用程序類……您都必須實現一種覆蓋方法,如下所示……

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

確保您在動態功能模塊中沒有任何啟動器活動(因為它會在手機上創建另一個看起來不合適的應用程序圖標)。
我早些時候遇到過這個問題,它對我有用......我希望你能得到你的解決方案。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM