How to use Data Binding and Kotlin in Android Studio 3.0.0

UPD: This was fixed for Android Gradle plugin 3.0.0-alpha3, in yout project root build.gradle, change the buildscript dependencies to use

classpath 'com.android.tools.build:gradle:3.0.0-alpha3'

This is actually a bug in the Kotlin Gradle plugin 1.1.2-4 inter-operation with the Android Gradle plugin 3.0.0-alpha1, caused by how the inputs and outputs of the tasks are set (and thus how the tasks are connected with the depends-on relation).

Thanks @VyacheslavGerasimov for creating the issue KT-17936.


As a temporary workaround, you can try to revert to Kotlin Gradle plugin 1.1.2-2 and disable incremental compilation:

In your project’s root build.gradle, change the version of the Kotlin Gradle plugin:

buildscript {
    ...
    dependencies {
        ...
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-2'
    }
}

Add local.properties to the project root, with the following line:

kotlin.incremental=false

It is a known issue that the Kotlin Gradle plugin 1.1.2-2 and below crashes with the newest AGP versions, and disabling incremental compilation seems to fix that crash.

Leave a Comment