发布apk中的Firebase IllegalAccessException

时间:2016-07-29 03:11:56

标签: android firebase apk firebase-realtime-database firebaseui

我在firebase项目控制台中为debug和release keystore添加了SHA1。我还在应用中通过google-services.json文件进行了更新。 Debug apk工作正常并访问firebase的所有实时数据库但是当我构建release apk时,我在访问Firebase数据库时遇到以下异常。

07-29 08:48:04.527 20997-20997/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.entrance.nepal, PID: 20997
    java.lang.RuntimeException: java.lang.IllegalAccessException: java.lang.Class<com.tenhaff.uniingress.fragments.UserListFragment$UserViewHolder> is not accessible from java.lang.Class<com.firebase.ui.database.FirebaseRecyclerAdapter>
        at com.firebase.ui.database.FirebaseRecyclerAdapter.onCreateViewHolder(FirebaseRecyclerAdapter.java:171)
        at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5779)
        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5003)
        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4913)
        at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
        at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
        at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
        at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
        at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3260)
        at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3069)
        at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518)

2 个答案:

答案 0 :(得分:5)

ViewHolder类应该是公共的而不是私有的或受保护的。这是因为proguard。

答案 1 :(得分:0)

你有proguard-rules.pro吗?如果您使用过该文件,请检查proguard for firebase。