How to upgrade ProGuard for Android?

不问归期 提交于 2019-12-03 10:51:21

These days ProGuard is a dependency of the Android Gradle plugin, and is usually updated along with it. Looking at the output of ./gradlew buildEnvironment (supported since Gradle 2.10) you will see something like

classpath
+--- com.android.tools.build:gradle:2.2.3
|    \--- com.android.tools.build:gradle-core:2.2.3
...
|         +--- net.sf.proguard:proguard-gradle:5.2.1
|         |    \--- net.sf.proguard:proguard-base:5.2.1

If you want to use another ProGuard version than the one the Android Gradle plugin depends on you can override it like

buildscript {
    configurations.all {
        resolutionStrategy {
            // We want version 5.3.2 instead of 5.2.1.
            force 'net.sf.proguard:proguard-gradle:5.3.2'
        }
    }
}

Modify your build.gradle like so:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ...
    dependencies {
        classpath 'net.sf.proguard:proguard-gradle:6.1.1' // <-- Add this line
        ...
    }
}

You don't have to manually download it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!