简体   繁体   中英

How can I solve this error : Data Binding annotation processor version needs to match the Android Gradle Plugin version

I am trying to data bind my project but I am getting this error in my Gradle file I am a beginner so let me know which files you need or what other information do you need more?

Data Binding annotation processor version needs to match the Android Gradle Plugin version. You can remove the kapt dependency androidx.databinding:databinding-compiler:7.1.0-alpha01 and Android Gradle Plugin will inject the right version.

build.gradle (:app)

plugins {
    id 'com.android.application'
    id 'kotlin-android'
//    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
//    id "androidx.navigation.safeargs.kotlin"
    id 'androidx.navigation.safeargs.kotlin'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.example.todoappstevdzaskillshare1"
    minSdkVersion 26
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}

dataBinding {
    enabled = true
 }
} 

 dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//DataBinding
kapt 'androidx.databinding:databinding-compiler:7.1.0-alpha01'

// Navigation Component
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

// Room components
implementation "androidx.room:room-runtime:2.3.0"
kapt "androidx.room:room-compiler:2.3.0"
implementation "androidx.room:room-ktx:2.3.0"
androidTestImplementation "androidx.room:room-testing:2.3.0"

// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"

}

NOTE: Let me know which more files do you need and I will edit the question.

You need to delete this line of code kapt'androidx.databinding:databinding-compiler:7.1.0-alpha01' and recompile. According to Google's open databinding document, the way to open databinding is:

android {
        ...
        dataBinding {
            enabled = true
        }
    }

I think databinding is already enabled in your gradle. So just delete the dependency and this error shouldn't occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM