【问题标题】:Android Room Persistence Library Proguard ConfigurationAndroid Room Persistence Library Proguard 配置
【发布时间】:2017-07-27 07:25:44
【问题描述】:

我正在使用 Android Room Persistence Library 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

【问题讨论】:

    标签: android proguard android-proguard android-room


    【解决方案1】:

    您可以在proguard中添加以下行而不是keep

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

    【讨论】:

    • 成功了。出于某种原因,我总是对在 proguard 中使用 dontwarn 持怀疑态度:P 非常感谢:D
    猜你喜欢
    • 2018-06-19
    • 1970-01-01
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    • 2018-03-28
    • 2017-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多