在我的应用程序中,我想使用 Room
使用库数据库 , 最后为 生成 APK 我启用 缩小 Build.Gradle
中的选项 ( proguard ) .
我使用以下版本的 Room 库:
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
我在 proguard-rules 中写了以下代码:
-dontwarn class android.arch.persistence.room.paging.LimitOffsetDataSource
-dontwarn interface android.arch.persistence.room.paging.LimitOffsetDataSource
-dontwarn class android.arch.util.paging.CountedDataSource
-dontwarn interface android.arch.util.paging.CountedDataSource
但是当生成 APK 在
Build
中显示以下错误标签:Unknown option 'android.arch.persistence.room.paging.LimitOffsetDataSource' in line 39 of file '/Volumes/M/Test Projects/MyApp/app/proguard-rules.pro'
显示此行的错误:
-dontwarn class android.arch.persistence.room.paging.LimitOffsetDataSource
如何解决这个问题?
最佳答案
如果你使用 androidx
-keep class * extends androidx.room.RoomDatabase
-keep @androidx.room.Entity class *
-dontwarn androidx.room.paging.**
关于java - 如何在 Android 上为 Room 库设置 proguard 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53700773/