BindingExtension icon indicating copy to clipboard operation
BindingExtension copied to clipboard

NullPointerException when proguard is enabled

Open jimlyas opened this issue 3 years ago • 3 comments

So I'm getting this error when enabling proguard:

Caused by: java.lang.RuntimeException: javaClass.superclass must not be null
        at na4.z(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.0.0:10)
        at com.devbase.presentation.viewbinding.DevActivity.onCreate(DevActivity.kt:3)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)

I deduce because of this.

When proguard is disabled, all is running well.

Thanks in advance.

jimlyas avatar Mar 25 '22 04:03 jimlyas

Hi, not sure if you follow this proguard rule already?

First of all, BindingExtension using refelction a lot to link many things internally in order to provide simple usage. To prevent having trouble with proguard, please remember to exclude ViewBinding related method in your proguard-rules file like this:

-keepclassmembers class * implements androidx.viewbinding.ViewBinding { public static ** inflate(...); }

https://github.com/Jintin/BindingExtension#usage

Jintin avatar Mar 25 '22 11:03 Jintin

Yes, I have. I included it already in my proguard configuration.

jimlyas avatar Mar 26 '22 08:03 jimlyas

If it works without proguard means there's something in proguard affect the binding process. May you describe more about your class hierarchy like is DevActivity inherit from BindingActivity directly or what's the different.

Jintin avatar Apr 01 '22 15:04 Jintin