android:kotlin如何解决数据绑定错误

时间:2019-02-07 21:14:29

标签: android kotlin android-gradle build.gradle

我将kotlin与android vision api一起用于人脸检测。当我尝试运行该项目时,构建失败。enter image description here

它给出了 kotlin编译错误。我想在kotlin数据绑定,gradle等方面肯定存在一些版本冲突。我尝试了this这样的stackoverflow帖子中的各种答案,但可以找不到解决方法。

这是我的build.gradle(app)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
    applicationId "com.android.ex1"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner         "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dataBinding {
    enabled = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-vision:11.8.0'
kapt "com.android.databinding:compiler:3.2.0-alpha10"

implementation "android.arch.persistence.room:runtime:1.0.0"
kapt "android.arch.persistence.room:compiler:1.0.0"
}

这是我的build.gradle(root)

buildscript {
ext.kotlin_version = '1.3.10'
ext.gradle_version = '3.2.0-alpha10'
repositories {
    google()
    jcenter()
    maven { url "https://maven.google.com" }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10"
    classpath 'com.google.gms:google-services:4.2.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://maven.google.com" }
}
}

task delete(type: Delete) {
delete rootProject.buildDir
}

任何帮助都会非常有用。谢谢!!

1 个答案:

答案 0 :(得分:0)

请检查此

implementation fileTree(include: ['*.jar'], dir: 'libs')

还有

    ext.gradle_version = '3.2.0-alpha10'

   classpath 'com.android.tools.build:gradle:3.3.1'

渐变版本不相同