airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.53k stars 728 forks source link

ViewBindingKotlinModel Proguard problem with latest gradle #1365

Open AbdelrahmanHesham14 opened 1 year ago

AbdelrahmanHesham14 commented 1 year ago
Fatal Exception: java.lang.NullPointerException: null cannot be cast to non-null type java.lang.Class<*>
       at com.qawafel.core.epoxy.ViewBindingKotlinModelKt.getSuperclassParameterizedType(ViewBindingKotlinModel.kt:73)
       at com.qawafel.core.epoxy.ViewBindingKotlinModelKt.getSuperclassParameterizedType(ViewBindingKotlinModel.kt:73)
       at com.qawafel.core.epoxy.ViewBindingKotlinModelKt.getSuperclassParameterizedType(ViewBindingKotlinModel.kt:73)
       at com.qawafel.core.epoxy.ViewBindingKotlinModelKt.getSuperclassParameterizedType(ViewBindingKotlinModel.kt:73)
       at com.qawafel.core.epoxy.ViewBindingKotlinModelKt.getBindMethodFrom(ViewBindingKotlinModel.kt:64)
       at com.qawafel.core.epoxy.ViewBindingKotlinModelKt.access$getBindMethodFrom(ViewBindingKotlinModel.kt:1)
       at com.qawafel.core.epoxy.ViewBindingKotlinModel$bindingMethod$2.invoke(ViewBindingKotlinModel.kt:29)
       at com.qawafel.core.epoxy.ViewBindingKotlinModel$bindingMethod$2.invoke(ViewBindingKotlinModel.java:29)
BlackFish768 commented 1 year ago

Same here. +1

I added this in Proguard as mentioned in the ViewBindingKotlinModel class

-keepclassmembers class * extends androidx.viewbinding.ViewBinding { public static *** bind(android.view.View); }

but still getting the same NullPointerException.

AbdelrahmanHesham14 commented 1 year ago

@BlackFish768 Yes it's very weired @elihart Please advise here

lwirasatria99 commented 12 months ago

me too, error when minifyEnable = true I use gradle 8.1.0

john-tadebois commented 12 months ago

I get the same error with the following specs:

AGP 8.0.0 com.airbnb.android:epoxy - v5.1.3 Same stacktrace as posted in the details of this issue.

AbdelrahmanHesham14 commented 11 months ago

No response from the team till now ! Anyone found a solution ?!

shawnlinboy commented 11 months ago

Related issue: #1122

cemore2048 commented 8 months ago

Don't know how helpful this is a year and a half later. When you update to AGP 8 it forces android.enableR8.fullMode to true. it's a more aggressive code minification. you have to explicitly set it to false in your gradle.properties file

android.enableR8.fullMode=false

That should avoid the need to figure out what rule to add

Nephys222 commented 4 months ago

@cemore2048 solutions fixed for me. But does it acceptable to close the bug.