R8 fullmode Causes java.lang.RuntimeException: Invalid TypeToken; must specify type parameters
daniel-waiguru opened this issue · 8 comments
Using Kodein 6.2.1 with r8 fullmode enabled causes this crash
java.lang.RuntimeException: Unable to instantiate application <packagename>.Application package <package_name: java.lang.RuntimeException: Invalid TypeToken; must specify type parameters at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1477) at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1399) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6830) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2145) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:8010) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957) Caused by: java.lang.RuntimeException: Invalid TypeToken; must specify type parameters at org.kodein.di.TypeReference.<init>(SourceFile:272) at <pacckagname>.Application$special$$inlined$instance$default$1.<init>(SourceFile:282) at <packagename>.Application.<init>(SourceFile:282) at java.lang.Class.newInstance(Native Method) at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76) at androidx.core.app.CoreComponentFactory.instantiateApplication(SourceFile:52) at android.app.Instrumentation.newApplication(Instrumentation.java:1232)
You can add pro guard rules like
https://kosi-libs.org/kodein/7.21/framework/android.html#_proguard_configuration.
Latest versions of Kodein embed them already.
I have added these rules but still the error persists
I'll have a look. Trying to reproduce.
Also, why are you on Kodein 6.2.1
?
Did you try to add proguard rules for TypeReference
?
Updating the Kodein version necessitates regression testing which is not in the pipeline, I have these rules https://kosi-libs.org/kodein/7.21/framework/android.html#_proguard_configuration in my proguard rules
Those rules only apply for 7.6+. Old Kodein versions have a different type system. So the rules should be different. You should add TypeReference to your rules.
Can I kindly get the rules I need for Kodein 6.2.1
I don't really know, looking at old code here, here and here, rules could be those:
-keep, allowobfuscation, allowoptimization class org.kodein.di.Typed
-keep, allowobfuscation, allowoptimization class org.kodein.di.TypeToken
-keep, allowobfuscation, allowoptimization class org.kodein.di.CompositeTypeToken
-keep, allowobfuscation, allowoptimization class org.kodein.di.JVMTypeToken
-keep, allowobfuscation, allowoptimization class org.kodein.di.WrappingTest
-keep, allowobfuscation, allowoptimization class * extends org.kodein.di.Typed
-keep, allowobfuscation, allowoptimization class * extends org.kodein.di.TypeToken
-keep, allowobfuscation, allowoptimization class * extends org.kodein.di.CompositeTypeToken
-keep, allowobfuscation, allowoptimization class * extends org.kodein.di.JVMTypeToken
-keep, allowobfuscation, allowoptimization class * extends class org.kodein.di.WrappingTest