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...

Kacper
  • 620
  • 1
  • 7
  • 16
  • 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. – Mark Mar 06 '17 at 18:44
  • So i should change apply plugin: 'com.neenbedankt.android-apt' to apply plugin: 'com.neenbedankt.annotationProcessor'? – Kacper Mar 06 '17 at 18:59
  • No @K.Kempski you don't have to apply any plugin now. Simply use annotationProcessor or provide in app gradle. – Priyam Gupta Apr 30 '17 at 10:03

4 Answers4

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

Mark
  • 9,604
  • 5
  • 36
  • 64
  • 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 ? – legalimpurity Mar 09 '17 at 16:49
  • @legalimpurity 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? – Mark Mar 09 '17 at 22:20
  • I also have the same issue as @legalimpurity is describing. – tricknology Mar 10 '17 at 00:57
  • @tricknology see this: https://bitbucket.org/hvisser/android-apt/issues/73/no-longer-compatible-with-gradle-at-v230 its not just about Butterknife (although this OP was) it is to do with android-apt no longer be supported – Mark Mar 10 '17 at 01:38
  • 1
    @tricknology : 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 ? – legalimpurity Mar 10 '17 at 08:34
  • @tricknology : I mean, I am still not able to remove that error. – legalimpurity Mar 10 '17 at 11:32
  • @legalimpurity do you have any submodules that might be using it? As a workaround just downgrade the gradle plugin. – Mark Mar 10 '17 at 22:59
  • @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. – tricknology Mar 11 '17 at 01:58
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'
Milan Hlinák
  • 4,260
  • 1
  • 30
  • 41
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'
Akinola Olayinka
  • 841
  • 7
  • 11
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'
Hossein Kurd
  • 3,184
  • 3
  • 41
  • 71