When creating a APK with proguard enabled, the following exception is thrown when using the FirebaseRecyclerAdapter from the Firebase-UI library (com.firebaseui:firebase-ui:0.3.0
):
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
at com.firebase.ui.FirebaseRecyclerAdapter.onCreateViewHolder(FirebaseRecyclerAdapter.java:168)
The debug version (without proguard) works fine. Who has a working proguard config for Firebase-UI?
My current proguard config looks like this (only the Firebase related parts):
-optimizationpasses 5
-keepattributes SourceFile,LineNumberTable,Exceptions, Signature, InnerClasses,*Annotation*
-keepnames class ** { *; }
-keep class com.firebase.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
Solved this by moving the ViewHolder
classes that are used by the FirebaseRecyclerAdapter
to a dedicated package (e.g. com.mypackage.myapp.viewholders) and adding a rule within the proguard configuration to prevent that classes within this package become obfuscated by proguard:
-keep class com.mypackage.myapp.viewholders.** { *; }
Well, I had my ViewHolder
inside relative FirebaseRecyclerAdapter
as an inner class and gave me this error. Making the inner class has solved the problem.
Also https://github.com/firebase/FirebaseUI-Android/issues/46#issuecomment-167373575 states same thing with an addition.
Inner class ViewHolder
must be public
and static
so that it could be initiated via reflection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With