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,904
  • 1
  • 17
  • 34

4 Answers4

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,559
  • 4
  • 27
  • 41
  • 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,515
  • 29
  • 48
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
  • 3,850
  • 1
  • 30
  • 41
0
To use Butter Knife in directly project:
dependencies {
  implementation 'com.jakewharton:butterknife:9.0.0-rc2'
  annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
}

To use Butter Knife in a library, add the plugin to your buildscript:

buildscript {
  repositories {
    mavenCentral()
   }
  dependencies {
    classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
  }
}

apply it in your module:

apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
Makvin
  • 3,083
  • 24
  • 26