android - 发布 apk 中的 Firebase IllegalAccessException

标签 android firebase apk firebase-realtime-database firebaseui

我在 firebase 项目控制台中为调试和发布 keystore 添加了 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)

最佳答案

ViewHolder 类应该是公共(public)的,而不是私有(private)的或 protected 。这是因为proguard。

关于android - 发布 apk 中的 Firebase IllegalAccessException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38649951/

相关文章:

java - 如何在 Eclipse for android 中设置自定义 keystore 以进行调试

android - 使用 Android Studio 生成未签名的发布 APK

android - 如何在前台运行 GcmListenerService

android - 我无法从我的 XML 资源中读取 AttributeSet

firebase - Flutter 中从 Firestore 查询单个文档(cloud_firestore 插件)

java - 无法在 Marathon 应用程序中将 java.lang.String 类型的值转换为 double

android - Volley 获取请求 : onResponse is never called

android - JSON 解析一个包含两个数组列表的数组

ios - Firebase iOS - 从其他 View Controller 访问用户对象

android - "apktool: command not found"错误