29

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.

9
  • What features to do need that you don't already have? Commented Feb 27, 2017 at 19:02
  • In order to compile with Android Target SDK 24+, Java version 1.8 is required. But Java 1.8 is incompatible with Proguard 4.7. Commented Feb 27, 2017 at 20:18
  • Then how are developers compiling and still releasing their code? Did you enable the Jack compiler? Commented Feb 27, 2017 at 20:20
  • It is possible to export APK if all target SDK's are set to Android 6.0 (api23). I don't know what Jack compiler is. Commented Feb 27, 2017 at 20:52
  • You have to enable Jack compilation to even use the Java 8 featureset... developer.android.com/guide/platform/j8-jack.html Commented Feb 27, 2017 at 20:58

3 Answers 3

54

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' } } } 
Sign up to request clarification or add additional context in comments.

Comments

15

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.

1 Comment

This helped when I was getting a Unity Android build error (Unsupported version number [55.0] (maximum 54.0, Java 10))
1

Do not use a force resolution strategy to upgrade Proguard. Instead declare the dependency in the Top-level build.gradle file such as -

buildscript { dependencies { classpath 'net.sf.proguard:proguard-gradle:6.1.1' } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.