Proguard configuration for Firebase-UI library

倾然丶 夕夏残阳落幕 提交于 2020-08-17 06:57:27

问题


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.** { *; }

回答1:


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.** { *; }



回答2:


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.



来源:https://stackoverflow.com/questions/34710582/proguard-configuration-for-firebase-ui-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!