How to use Data Binding and Kotlin in Android Studio 3.0.0

后端 未结 4 1885
庸人自扰
庸人自扰 2020-11-29 22:40

I just started to use Android Studio 3.0.0, but every time I try to build my project I get this error:

Error:Circular dependency between the following tasks:         


        
4条回答
  •  囚心锁ツ
    2020-11-29 23:24

    For those still looking for a proper solution, Google has already fixed this issue in Android Studio 3.0 Canary 3 build.

    Friday, June 2, 2017

    We have just released Android Studio 3.0 Canary 3 to the Canary and Dev Channels. The Android Gradle Plugin 3.0.0-alpha3 was also released through maven.google.com. This release has fixes to Gradle, Kotlin, and many other fixes. We continue to fix bugs in all areas of Studio 3.0 as we stabilize our features, so please continue to pass on feedback.

    Working gradle configuration:

    build.gradle (project)

    buildscript {
        ext.kotlin_version = '1.1.2-4'
        repositories {
            jcenter()
            maven {
                url 'https://maven.google.com'
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    

    build.gradle (module)

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-kapt'
    
    
    android {
        dataBinding.enabled = true
    }
    dependencies {
        kapt "com.android.databinding:compiler:3.0.0-alpha3"
    }
    

提交回复
热议问题