12

How can I find out which version of R8 is being used by the Android Gradle Plugin for let's say 4.0.1?

buildscript {
  repositories {
    google()
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:4.0.1'
  }
}
Niklas
  • 23,674
  • 33
  • 131
  • 170

2 Answers2

18

This can be done by writing println(com.android.tools.r8.Version.getVersionString()) anywhere in your Gradle script and executing any Gradle Task or just calling the Gradle Wrapper.

buildscript {
  repositories {
    google()
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:4.0.1'
  }
}

println(com.android.tools.r8.Version.getVersionString())

Output:

$ ./gradlew

2.0.88 (build 19b089a1d5a73df8f00a27fda8b29b49782c621c from go/r8bot (luci-r8-ci-archive-0-z0tz))
Niklas
  • 23,674
  • 33
  • 131
  • 170
3

Another option is to pass --info to the Gradle build.

Running ./gradlew --info app:assembleRelease (AGP 4.1.1) includes the following info:

R8 is a new Android code shrinker. If you experience any issues, please file a bug at
https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can
disable R8 by updating gradle.properties with 'android.enableR8=false'.
Current version is: 2.1.75 (build 7c61a6224c35283ccaad7e85c848e3a71a716763 from go/r8bot (luci-r8-custom-ci-xenial-6-i8ri)).

However that will only be displayed if R8 is actually invoked.

sgjesse
  • 3,793
  • 14
  • 17