本文介绍了Firebase-UI库的Proguard配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建启用了proguard的APK时,从Firebase-UI库(

通过移动 ViewHolder 类被 FirebaseRecyclerAdapter 使用到一个专用包(例如com.mypackage.myapp.viewholders),并在proguard中添加一个规则配置,以防止这个包内的类被proguard混淆:

  -keep class com.mypackage.myapp.viewholders。** {*; } 


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

这篇关于Firebase-UI库的Proguard配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 04:35
查看更多