Home > OS >  Execution failed task ':app:kaptGenerateStubsDebugKotlin'
Execution failed task ':app:kaptGenerateStubsDebugKotlin'

Time:05-07

When I want to run the app, I get the following Build output:

Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
   > Could not find com.android.databinding:compiler:4.2.1.

I searched it already up on stackoverflow but it didn't help. I am stuck on this issue for 2 days now and it's driving me nuts :/ My project build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.10"
    ext.version_navigation = "2.3.0"
    ext.version_core = "1.3.1"
    ext.version_constraint_layout = "2.0.0-rc1"
    ext.version_lifecycle_extensions = "2.2.0"
    ext.version_material = "1.2.0"

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


        // Navigation
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$version_navigation"

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


allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

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

My module build.gradle file:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'androidx.navigation.safeargs'
    id 'kotlin-kapt'
}

android {

    buildFeatures {
        dataBinding = true
        viewBinding = true
    }

    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.commentapp"
        minSdkVersion 27
        targetSdkVersion 31
        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'
    }
}

dependencies {

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

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
    testImplementation 'junit:junit:4. '
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


    //Navigation
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    kapt "com.android.databinding:compiler:4.2.1"
}


I hope you can help me with that. Write me if you need more information on my project (e.g. fragment file or something like that).

CodePudding user response:

you dont need to put

kapt "com.android.databinding:compiler:4.2.1"

only need enable data binding in the gradle, and you did this

documentation: https://developer.android.com/jetpack/androidx/releases/databinding

  • Related