Jintin/BindingExtension

NullPointerException when proguard is enabled

jimlyas opened this issue · 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.

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

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

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.