2022年6月30日 星期四

Android Dynamic Feature Module(DFM) 動態模組

記錄一些加入動態模組遇到的問題,介紹與開始使用可以參考:https://medium.com/@kris1837/how-to-start-activity-from-dynamic-feature-module-on-android-75a55d782e6a

https://levelup.gitconnected.com/how-to-download-dynamic-feature-modules-a6f6036e183b

https://medium.com/mindorks/dynamic-feature-modules-the-future-4bee124c0f1

https://developer.android.com/guide/playcore/feature-delivery


Resources$ NotFoundException

一開始不知道複製到哪篇文章的 code,在 activity 內的 SplitCompat.installActivity帶入 context,導致每次都會出現 Resources$ NotFoundException,在網路查了許久也沒找到原因,當找不到原因,就表示你寫錯了!!!重新看了幾篇文章,這邊是要帶入 this :>


override fun attachBaseContext(context: Context) {

    super.attachBaseContext(context)

    SplitCompat.installActivity(this)

}


startActivity

覺得這個方法最好用

 val intent = Intent(this, Class.forName("com.bbb.aaa.TestActivity"))

 intent.putExtra("AAA", value)

 startActivity(intent)


koin 的適配

https://medium.com/swlh/app-failures-by-koin-story-2-unreliable-dynamic-loading-d5c810fe29c3


Resource shrinker cannot be used for multi-apk applications

把 Resource shrinker 關掉


All modules with native libraries must support the same set of ABIs

包版後因為 DFM 跟 base module 依賴的 libs 不同可能最後支援的版本會不同,所以DFM 跟base module 的依賴最好一樣,不然就得找出是那個依賴的問題。

本來想說就是因為某些功能太肥,想要拆成 DFM,但是因為這個限制還是得在 base    先依賴,apk 大小還是降不下來QQ

測試需要使用內部應用程式分享


沒有留言:

張貼留言