Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Annotation processor '__gen.AnnotationProcessorWrapper_debug_android_databinding_annotationprocessor_ProcessDataBinding' not found

So, I'm trying to build my Android project with Kotlin and add Android DataBinding library into it. In Android Studio 2.2.3 there was no problem with it. But after update to the latest Android Studio version (2.3.0) I got this error when try to run the app.

enter image description here

Here is my Project's build.gradle

buildscript {

    ext.kotlinVersion = '1.1.0'
    ext.androidGradlePluginVersion = '2.3.0'

    ...

    dependencies {
        classpath "com.android.tools.build:gradle:${androidGradlePluginVersion}"

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

...

And here is my App's build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    ...

    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    dataBinding.enabled = true
}

dependencies {

    ...
    compile "com.google.dagger:dagger:${daggerVersion}"
    compile "com.google.dagger:dagger-compiler:${daggerVersion}"
    provided 'javax.annotation:jsr250-api:1.0'
    kapt "com.android.databinding:compiler:$androidGradlePluginVersion"
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}

Is there something that I have to updated to make Kotlin work with Android DataBinding library? Please help. Thanks in advance.

EDIT:

Based on @Rene answer, I tried to replace kotlin-android-extensions with kotlin-kapt , But when I tried to sync gradle I got another error.

enter image description here

enter image description here

Anyone what's wrong from this error? Thanks

FIX THAT WORKS:

Turns out I just need to update some line related with Dagger2 in my gradle. I REMOVE this line below from my Project's build.gradle file.

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

And update the dependencies related Dagger2 in my app's build.gradle file to be like this.

compile "com.google.dagger:dagger:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
provided 'org.glassfish:javax.annotation:10.0-b28'

I got this settings from this article

Here is my build.gradle content that WORKS for me.

Project's build.gradle

buildscript {
    ext.kotlinVersion = '1.1.0'
    ext.androidGradlePluginVersion = '2.3.0'

    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:${androidGradlePluginVersion}"

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

app's build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    dexOptions {
        maxProcessCount 2
        javaMaxHeapSize "2g"
    }
    defaultConfig {
        applicationId "my.application.id"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    dataBinding.enabled = true
}

kapt {
    generateStubs = true
}

ext {
    supportLibVersion = '25.2.0'
    retrofitVersion = '2.2.0'
    daggerVersion = '2.7'
    googleServiceVersion = '10.2.0'
    rxJavaVersion = '2.0.6'
    rxAndroidVersion = '2.0.1'
    glideVersion = '3.7.0'
    constraintLayoutVersion = '1.0.1'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'

    compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
    compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
    compile "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
    compile 'com.squareup.okhttp3:logging-interceptor:3.3.0'

    compile "com.android.support:support-compat:${supportLibVersion}"
    compile "com.android.support:support-core-utils:${supportLibVersion}"
    compile "com.android.support:support-core-ui:${supportLibVersion}"

    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile "com.android.support.constraint:constraint-layout:${constraintLayoutVersion}"

    compile "com.google.dagger:dagger:${daggerVersion}"
    kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
    provided 'org.glassfish:javax.annotation:10.0-b28'

    compile 'com.android.support:multidex:1.0.1'

    compile('com.mikepenz:fastadapter:1.8.2@aar') {
        transitive = true
    }
    compile 'com.mikepenz:fastadapter-extensions:1.8.0@aar'
    compile 'com.mikepenz:materialize:1.0.0@aar'


    compile "com.google.android.gms:play-services-location:${googleServiceVersion}"
    compile "com.google.android.gms:play-services-maps:${googleServiceVersion}"

    compile "io.reactivex.rxjava2:rxjava:${rxJavaVersion}"
    compile "io.reactivex.rxjava2:rxandroid:${rxAndroidVersion}"

    compile "com.github.bumptech.glide:glide:${glideVersion}"

    kapt "com.android.databinding:compiler:$androidGradlePluginVersion"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"

    compile 'de.hdodenhof:circleimageview:2.1.0'
}

repositories {
    mavenCentral()
}

Thanks.

like image 437
Khairil Ushan Avatar asked Mar 17 '26 05:03

Khairil Ushan


1 Answers

Starting with Kotlin 1.1 I've had to switch to the newer Kotlin annotation processor.

Apply it like so:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

I've found it first mentioned in the 1.0.6 release at kotlin-1-0-6-is-here

like image 167
Rene Avatar answered Mar 19 '26 19:03

Rene