Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade ProGuard for Android?

I used Android SDK Manager to download the latest version of Android SDK. But ProGuard was not updated and remained at version 4.7.

Is it necessary to manually download ProGuard from its website and unzip it to \android-sdk\tools\proguard ?

Or will Android SDK always use Version 4.7? It has been this way for 4 years.

like image 476
activity Avatar asked Feb 27 '17 18:02

activity


People also ask

How do I add ProGuard to gradle?

To actually apply the plugin to your project, just add the line to your module level build. gradle(. kts) file after applying the Android Gradle plugin as shown below. ProGuard expects unobfuscated class files as input.


2 Answers

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'         }     } } 
like image 70
sschuberth Avatar answered Sep 22 '22 06:09

sschuberth


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.

like image 20
deej Avatar answered Sep 24 '22 06:09

deej