Closed RavioliWonton closed 3 years ago
I believe there is something weird about multidex with kotlin. It's not work by configuring multiDexKeepFile. I will keep tracking this issue and close this for it's not Splitties's fault.
I understand what happened. Since migrating to androidx.startup, I cannot use appCtx in Application's static code block or companion object in kotlin(which is initialized through Application's construction, this instance is not accessible refer to document), there is a reproduce project. If this should be an intended behaviour, please close this, or I can issue a bug report to google. Reopen the issue.
You can workaround by calling context?.injectAsAppCtx()
early in an init
block in your Application
class.
context?.injectAsAppCtx()
Thanks for the reply, but it's not working in initialization of Application class. Inject into applicationContext will get NullPointerException, and inject into baseContext will get the same error of NoClassDefFoundError.
Can you make a small reproducing project?
Can you make a small reproducing project?
Sure, it's here.
The project you shared doesn't reproduce the bug it seems. The app doesn't crash on launch, and I see no relevant logs.
The project you shared doesn't reproduce the bug it seems. The app doesn't crash on launch, and I see no relevant logs.
I'm sorry I forget to mention that this situation will only appear on devices under api 21, which need MultiDex to move past 65K limitation.
Hello, can you try to use AndroidX App Startup 1.1.0-rc01?
See the related changelog here: https://developer.android.com/jetpack/androidx/releases/startup#1.1.0-rc01
Should be fixed in 3.0.0-rc01 via AndroidX App Startup upgrade.
It fixed my problem, thank you!
After upgraded to Kotlin 1.5.21, I came into this error with com.louiscad.splitties:splitties-appctx:3.0.0-beta02: