gradle 3.2.1的数据绑定问题 [英] Issue with data binding with gradle 3.2.1

查看:62
本文介绍了gradle 3.2.1的数据绑定问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将android studios 3.2.0更新到3.2.1时.我使用了数据绑定,当运行项目时向我显示这样的错误,如果我错了,请建议我.

When i have updated android studios 3.2.0 to 3.2.1. I have use data binding, when run project show me error like this, if i am wrong please suggest me.

Could not find com.android.databinding:compiler:3.2.1.
Searched in the following locations:
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar     
https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar

要求: 项目:app

Required by: project :app

project.gradle

project.gradle

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

app.gradle

app.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.taufik.kotlinbindingtest"
        minSdkVersion 19
        targetSdkVersion 28
        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:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    kapt "com.android.databinding:compiler:$gradle_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

如果我错了,请建议我.

If i am wrong please suggest me.

推荐答案

我寻找了很多解决方案,最后我发现问题出在依赖项之一中,所以我从app.gradle中删除了此kapt "com.android.databinding:compiler:$gradle_version"并成功运行了项目.

I looked for many solution and finally i found that problem was in one of Dependencies, So I removed this kapt "com.android.databinding:compiler:$gradle_version" from app.gradle and project run succeffully.

这篇关于gradle 3.2.1的数据绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆