Android Room持久化库Proguard配置

6

我正在使用Android Room持久化库1.0.0-alpha5。 在使用ProGuard编译时,我遇到了以下错误。

Warning:android.arch.persistence.room.paging.LimitOffsetDataSource: can't find superclass or interface android.arch.util.paging.CountedDataSource
Warning:android.arch.persistence.room.paging.LimitOffsetDataSource: can't find referenced class android.arch.util.paging.CountedDataSource
Warning:android.arch.persistence.room.paging.LimitOffsetDataSource$1: can't find referenced method 'void invalidate()' in program class android.arch.persistence.room.paging.LimitOffsetDataSource
Warning:there were 5 unresolved references to classes or interfaces.
Warning:there were 1 unresolved references to program class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.

我为Room配置的ProGuard如下:

-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
# Platform calls Class.forName on types which do not exist on Android to     determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters     and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
-keep class android.content.**
-dontwarn android.content.**
-keep class android.animation.**
-dontwarn android.animation.**
-keep class me.panavtec.drawableview.**
-dontwarn me.panavtec.drawableview.**
-keep class javax.annotation.concurrent.**
-dontwarn javax.annotation.concurrent.**
-keep class android.arch.persistence.room.paging.LimitOffsetDataSource
-keep interface android.arch.persistence.room.paging.LimitOffsetDataSource
-keep class android.arch.util.paging.CountedDataSource
-keep interface android.arch.util.paging.CountedDataSource

我需要帮助修复这个错误。我认为在Alpha 3之前不需要ProGuard配置,而且我没有测试过alpha 4。

1个回答

10

您可以将以下行添加到proguard中,而不是使用keep

-dontwarn android.arch.util.paging.CountedDataSource
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource

1
它奏效了。 因为某种原因,我总是有些怀疑在Proguard中使用dontwarn:P 非常感谢:D - user3425867

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接