Search code examples
androidandroid-r8

How to get version of R8 that is being used by the Android Gradle Plugin?


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

Solution

  • 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))
    

    This can also be added as a task to your Gradle script to not have it executed to configuration time:

    tasks.register("r8Version") {
        doLast {
            println(com.android.tools.r8.Version.getVersionString())
        }
    }
    

    Running the :app:r8Version task:

    $ ./gradlew :app:r8Version
    
    > Task :app:r8Version
    8.2.47 (build 62baf24ba2b71f4e5bc04c7f01930bc5d47b02be from go/r8bot (luci-r8-custom-ci-archive-0-19z6))