3

Based on ButterKnife lib, I upgrade to new version 8.5.1. I used

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

But it warns me in my Android Studio 2.3. And ButterKnife doesn't work(cannot bind view).

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

I change annotationProcessor to apt (I had plugin apply plugin: 'com.neenbedankt.android-apt' in my gradle) and it works as old version without warning (I used apt for old version 8.4.0)

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

I think Android Studio 2.3 is incomatible with Annottaion processing. I searched and found to enable Annotation Processors in Android Studio 2.2 but cannot find in Android Studio 2.3

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

Anyone can explain this problem? Thanks!

RoShan Shan
  • 2,924
  • 1
  • 18
  • 38

3 Answers3

6

kindly

//apply plugin: 'com.neenbedankt.android-apt'  <--remove this
apply plugin: 'com.jakewharton.butterknife'  <-- add this


dependencies {
    //classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  <-- remove this
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' <-- add this
}

then in app dependencies

//Butterknife

compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
ZeroOne
  • 8,996
  • 4
  • 27
  • 45
  • I will check it, thanks. But when we use `classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'` for parent gradle. We only need `apply plugin: 'com.jakewharton.butterknife'` for modules right. No need `compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'`? – RoShan Shan Mar 16 '17 at 04:44
  • so far as im concerned, `compile 'com.jakewharton:butterknife:8.5.1' ` and `annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'` is needed.. – ZeroOne Mar 16 '17 at 09:29
3

Simple and easy. Just add these lines to your build.gradle

compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
Rishav
  • 3,818
  • 1
  • 31
  • 49
0

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

Check my updated answer here.

Milan Hlinák
  • 4,260
  • 1
  • 30
  • 41