android - RecyclerView 项目内容不可见

标签 android android-studio layout android-recyclerview apk

使用 RecyclerView 显示来自 JSON 的数据,每个 Recycler Item 都包含一个图像,几个 TextViews

但是每当我运行我的应用程序时,我都会收到 RecyclerView 列表,但不会在其中获取内容和图像。

可能是什么原因?

proguard-rules.pro:

-dontwarn okio.**
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepclassmembers,allowobfuscation interface * {
    @retrofit.http.** <methods>;
}

-dontwarn com.squareup.okhttp.**
-keepattributes Signature

最佳答案

你的 Proguard 弄乱了你的 POJO。它被混淆了,因此不再起作用。这就是为什么在您为调试构建启用 minify 之后它也会发生。

您应该保留所有 POJO 及其成员,因为它们会被反射使用。从我从你的代码中看到的,你至少需要添加

-keep class **.CountryPojo { *; }

但这可能不是全部,您应该保留用于 POJO 的包的所有类和成员

-keep class pkg.of.the.pojos.** { *; }

关于android - RecyclerView 项目内容不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37069013/

相关文章:

android - 使用 Activity 和 MapActivity 时减少代码重复

安卓 SQLite 错误 "requesting column name with table name"

Android:错误:任务 ':app:transformClassesWithJarMergingForDebug' 执行失败

android - 如何使编辑字段android的固定大小

Android AutocompleteTextView 建议索引到 ListView

java - 如何迭代 Firebase 实时数据库中多个按键的子项?

android - 在 Android Studio 中的方法之间跳转,例如 Visual Studio/Eclipse

android - 在 Android 和 Gradle 中使用 SimpleXML

java - 如何更改 Android 示例主页应用程序中显示的缩略图数量?

css - dojo 中 tabContainer 的高度