如何修复这些proguard警告

时间:2016-10-01 19:13:38

标签: android android-studio proguard

我在我的项目中使用了第三方库,从那时起,proguard向我发出了这些警告,我无法与该库相关联,这是我正在使用的库:Lollipin。< / p>

警告我正在

Warning:android.databinding.DataBindingUtil: can't find referenced class android.databinding.DataBinderMapper
Warning:android.databinding.ViewDataBinding: can't find referenced class android.databinding.DataBinderMapper
Warning:there were 43 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.

我尝试了什么?

我已经像这样编辑了proguard-rules.pro

-keeppackagenames com.github.orangegangsters.lollipin

仍然没有去!我也试图清理和重建那个也没有成功的项目。

这是build.gradle:

apply plugin: 'com.android.application'

 android {
compileSdkVersion 24
buildToolsVersion '24.0.2'

defaultConfig {
    applicationId "com.example.teach"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 27
    versionName "5.0"
}
buildTypes {
    release {

        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }

}


}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.android.support:appcompat-v7:24.2.1'
compile('com.mikepenz:materialdrawer:5.6.0@aar') {
    transitive = true
}
compile ('com.github.orangegangsters:lollipin:2.0.0@aar') {
    transitive = true
}

 compile 'com.google.android.gms:play-services-ads:9.6.0'


}
apply plugin: 'com.google.gms.google-services'

请帮帮我!谢谢!

3 个答案:

答案 0 :(得分:22)

我有同样的问题,所以我将以下更改添加到我的proguard.cfg

-dontwarn android.databinding.**
-keep class android.databinding.** { *; }

-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

答案 1 :(得分:0)

尝试:

-dontwarn com.github.orangegangsters.lollipin

而不是

-keeppackagenames com.github.orangegangsters.lollipin

答案 2 :(得分:-3)

这是因为Lollipin使用数据绑定库。

只需添加到gradle:

dataBinding {
        enabled = true
}