exponea / exponea-android-sdk

MIT License
17 stars 16 forks source link

Exponea not initialized because of missing Gson Proguard/R8 rules #60

Closed LudoFarkas closed 1 year ago

LudoFarkas commented 1 year ago

Hi.

After enabling R8 full mode with the update of our development tools, Exponea does not initialize on start of our release app. This is due to missing Gson Proguard/R8 rules. See log:

Exponea Safe Mode wrapper caught unhandled error java.lang.ExceptionInInitializerError at com.exponea.sdk.ExponeaComponent.(SourceFile:62) at com.exponea.sdk.Exponea.initializeSdk(SourceFile:10) at com.exponea.sdk.Exponea.init(SourceFile:18) at xg.c.invokeSuspend(SourceFile:157) at xg.c.invoke(SourceFile:11) at rh.n.invokeSuspend(SourceFile:47) at rh.n.invoke(SourceFile:13) at kotlinx.coroutines.flow.j.c(SourceFile:81) at lf.l.invokeSuspend(SourceFile:47) at lf.l.invoke(SourceFile:13) at ys.c.h0(SourceFile:5) at nb.r0.A(SourceFile:10) at lf.m.i(SourceFile:7) at lf.g.a(SourceFile:6) at lf.d.invokeSuspend(SourceFile:33) at ve.a.resumeWith(SourceFile:9) at kotlinx.coroutines.k0.run(SourceFile:109) at kotlinx.coroutines.internal.e.run(SourceFile:12) at kotlinx.coroutines.scheduling.k.run(SourceFile:3) at kotlinx.coroutines.scheduling.b.run(SourceFile:80) Caused by: java.lang.RuntimeException: Missing type parameter. at com.google.gson.reflect.a.getSuperclassTypeParameter(SourceFile:27) at com.google.gson.reflect.a.(SourceFile:2)

We do not use Gson in our app, thus have no rules configured. Since the rules are transient, we believe they should be configured within Exponea.

This is our temporary fix:

-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

Exponea version: 3.6.1

adam1929 commented 1 year ago

Thank you @LudoFarkas for reporting. Proguard rules can be applied only on application side. As I investigate this, GSON provides some changes due to R8 recently, maybe it will fix somethings. Thank you