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.

Community
  • 1
  • 1
activity
  • 431
  • 1
  • 7
  • 9
  • What features to do need that you don't already have? – OneCricketeer Feb 27 '17 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. – activity Feb 27 '17 at 20:18
  • Then how are developers compiling and still releasing their code? Did you enable the Jack compiler? – OneCricketeer Feb 27 '17 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. – activity Feb 27 '17 at 20:52
  • You have to enable Jack compilation to even use the Java 8 featureset... https://developer.android.com/guide/platform/j8-jack.html – OneCricketeer Feb 27 '17 at 20:58
  • And this was posted about Proguard 3 years ago. https://www.guardsquare.com/en/blog/the_upcoming_jack_and_jill_compilers_in_android – OneCricketeer Feb 27 '17 at 21:02
  • Thanks. Is it possible to use Jack with Eclipse? – activity Feb 27 '17 at 21:04
  • Maybe... it's just a Gradle setting... Eclipse can use Gradle... I wouldn't know, though, I haven't developed Android on Eclipse in three years because it's been deprecated for a long time. – OneCricketeer Feb 27 '17 at 21:06
  • Am I correct in inferring from this that current Android Studio cannot (without installing third party tools) generate signed apks when target is set to current Android? Isn't that rather strange? – comodoro Mar 06 '17 at 18:01

3 Answers3

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'
        }
    }
}
sschuberth
  • 28,386
  • 6
  • 101
  • 146
13

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.

deej
  • 1,703
  • 1
  • 24
  • 26
  • This helped when I was getting a Unity Android build error (Unsupported version number [55.0] (maximum 54.0, Java 10)) – Visualspark Dec 15 '22 at 02:11
0

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'
    }
}