View Binding and Android Studio Versions

The documentation for view binding states:

Note: View binding is available in Android Studio 3.6 Canary 11+.

That’s not strictly accurate.

Things like view binding are not part of Android Studio. If they were, we could not use view binding in projects that are built from the command line or from a CI server.

The more accurate description is:

Note: View binding is available in Android Studio 3.6 Canary 11+, once you upgrade to 3.6.0-alpha11 or higher of the Android Gradle Plugin

For a new project created in Android Studio 3.6, you will get the corresponding Android Gradle Plugin line with a version matching that of Android Studio. But, if you open an existing project, you may have an older Android Gradle Plugin version in your Gradle scripts.

The real requirements for using view binding are:

  • Use 3.6.0-alpha11 or higher of the Android Gradle Plugin:
buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.0-alpha12'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
  • Use Gradle 5.6.1 or higher, as that is required by this version of the Android Gradle Plugin

  • Use Android Studio 3.6 Canary 11+, as Android Studio 3.5 (or older) will not open a project using 3.6.0-alpha11 or higher of the Android Gradle Plugin

For solo-developer projects, making these changes is easy. For team projects, everybody will need to switch to Android Studio 3.6 Canary 11+, which may or may not be practical, depending on your team’s stance on pre-release tools.