发布 apk 中的 Firebase IllegalAccessException
Firebase IllegalAccessException in release apk
我在 firebase 项目控制台中为调试和发布密钥库添加了 SHA1。我还通过应用程序中的 google-services.json 文件进行了更新。调试 apk 工作正常并访问 firebase 的所有实时数据库,但是当我构建发布 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)
你有proguard-rules.pro吗?如果您使用了该文件,请检查 proguard for firebase。
ViewHolder 类 应该是 public 而不是私有的或受保护的。是因为proguard.
我在 firebase 项目控制台中为调试和发布密钥库添加了 SHA1。我还通过应用程序中的 google-services.json 文件进行了更新。调试 apk 工作正常并访问 firebase 的所有实时数据库,但是当我构建发布 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)
你有proguard-rules.pro吗?如果您使用了该文件,请检查 proguard for firebase。
ViewHolder 类 应该是 public 而不是私有的或受保护的。是因为proguard.