Android ProGuard使用gradle插件3.0.1(4.1?)构建已签名的apk失败

时间:2017-11-28 19:55:54

标签: android android-studio android-gradle proguard android-proguard

ProGuard不断给出错误,不让我构建签名的APK: (full console output)

红线:

Warning: com.package.name.MainActivity$20$1: can't find referenced field 'android.widget.RadioGroup val$dialogReport' in program class com.package.name.MainActivity$20
Warning: com.package.name.MainActivity$20$1: can't find referenced field 'android.support.v7.app.AlertDialog val$dialog' in program class com.package.name.MainActivity$20
Warning: com.package.name.MainActivity$20$1: can't find enclosing method 'void onShow(android.content.DialogInterface)' in program class com.package.name.MainActivity$20
Warning: com.package.name.MainActivity$8$1: can't find referenced method 'int access$1100()' in program class com.package.name.MainActivity
Warning: com.package.name.MainActivity$8$1: can't find referenced method 'android.support.v4.util.ArrayMap access$1200()' in program class com.package.name.MainActivity
Warning: com.package.name.MainActivity$8$1: can't find referenced class com.package.name.MainActivity$DeleteSpotTask
Warning: com.package.name.MainActivity$8$1: can't find referenced class com.package.name.MainActivity$DeleteSpotTask
Warning: com.package.name.MainActivity$8$1: can't find referenced class com.package.name.MainActivity$DeleteSpotTask
Warning: com.package.name.MainActivity$8$1: can't find referenced method 'android.support.v4.util.ArrayMap access$1500()' in program class com.package.name.MainActivity
Warning: com.package.name.MainActivity$8$1: can't find referenced method 'void access$1600(com.package.name.MainActivity)' in program class com.package.name.MainActivity

My build.gradle

我的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

此问题在将com.android.tools.build:gradle:3.0.0更新为com.android.tools.build:gradle:3.0.1后开始发生。

com.android.tools.build:gradle:3.0.0

时编译时没有任何错误

1 个答案:

答案 0 :(得分:1)

在gradle部分中转到gradle-wrapper.properties文件

更改distributionUrl,

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip