Android Studio Warning: Using incompatible plugins for the annotation processing
Asked Answered
D

4

52

After update Android Studio to 2.3 version I have warning:

Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.

Any solutions? My app stopped working...

Dela answered 6/3, 2017 at 18:11 Comment(3)
Android studio now has inbuilt annotation processing at compile time - you can remove the use of the android-apt and use annotationProcessor instead. I don't know your particular usecase of andorid-apt but you should check the latest gradle setup for the dependency you're using it for.Chariness
So i should change apply plugin: 'com.neenbedankt.android-apt' to apply plugin: 'com.neenbedankt.annotationProcessor'?Dela
No @K.Kempski you don't have to apply any plugin now. Simply use annotationProcessor or provide in app gradle.Pomiculture
C
126

Your app level gradle dependencies should include (as per butterknife website instructions):

compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

You can remove the line :

apply plugin: 'com.neenbedankt.android-apt'

Annotation Processing became available in Android Gradle plugin (2.2 and later) so there is now no need to use the above plugin anymore if using this version of gradle or greater.

If you'd like to know how to turn annotation processing off and on and AS the setting is in :

Settings > Build, Execution, Deployment > Compiler > Annotation Processors

Chariness answered 6/3, 2017 at 22:44 Comment(8)
Hey, i have the same problem. But I do not have : apply plugin: 'com.neenbedankt.android-apt' OR annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' written in my build gradle file. I was using : compile 'com.jakewharton:butterknife:7.0.1' now, after i have added the updated libraries and annotationProcessor, i still cant get my project to run and have the same error. Any suggestions ?Rung
@Rung In your comment this : But I do not have : apply plugin: 'com.neenbedankt.android-apt' and this i still cant get my project to run and have the same error contradict what the error is in the OP question? If gradle is reporting Warning:Using incompatible plugins for the annotation processing: android-apt. then you have a conflict or outdated plugin. Or is this different to what you mean?Chariness
I also have the same issue as @Rung is describing.Lynnalynne
@Lynnalynne see this: bitbucket.org/hvisser/android-apt/issues/73/… its not just about Butterknife (although this OP was) it is to do with android-apt no longer be supportedChariness
@Lynnalynne : Thanks for sharing the link, I have gone through my build scripts and no where am i using android-apt, apt, androidTestApt, testApt ? any suggestions ?Rung
@Lynnalynne : I mean, I am still not able to remove that error.Rung
@Rung do you have any submodules that might be using it? As a workaround just downgrade the gradle plugin.Chariness
@legalimpurity, K. Kempski's solution below worked for me - removing the annotation processor in butterknife (just commented out the line altogether). I'm not sure how reasonable it is for you though.Lynnalynne
E
39

In my project I use, among other things, Butter Knife and Immutables. After adding Immutables I got the following warning

Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.

and ButterKnife stopped working.

My configuration was as follows:

build.gradle (Project: MyApplication)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

build.gradle (Module: app)

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

...

dependencies {

    ...

    // Butter Knife
    compile 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

    // Immutables
    apt 'org.immutables:value:2.4.4'
    provided 'org.immutables:value:2.4.4'
    provided 'org.immutables:builder:2.4.4'
    provided 'org.immutables:gson:2.4.4'

}

After changing

annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

to

apt 'com.jakewharton:butterknife-compiler:8.5.1'

warning disappeared and everything works as it should.

UPDATE

As Mark said, an annotation processor was included in the Gradle version 2.2 , so there is no reason to provide an extra one.

So:

1) Remove the class path for the apt from the build.gradle (Project: MyApplication)

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

2) Remove the plug in from the build.gradle (Module: app)

apply plugin: 'android-apt'

3) Change the dependencies from apt to the new annotationProcessor

annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor 'org.immutables:value:2.4.4'
Effectually answered 10/4, 2017 at 17:53 Comment(0)
J
2

To add to @Milan's answer, if you used the hotchemi permissiondispatcher library in your app level gradle file then you should replace it as follows:

Replace

apt 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'

with

annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
Jacquesjacquet answered 8/1, 2018 at 17:57 Comment(0)
O
0

At Project Gradle buildscript --> dependencies block, remove the second classpath line :

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    // classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

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

And at app Gradle dependencies block, change these lines, use api and annotationProcessor :

api 'com.google.dagger:dagger:2.19'
annotationProcessor 'com.google.dagger:dagger-compiler:2.19'

Also, remove this one:

//apply plugin: 'com.neenbedankt.android-apt'
Overlord answered 18/12, 2018 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.