ButterKnife not working with Jack?
Asked Answered
O

4

13

I just started a very simple project and tried to use both ButterKnife and Jack compiler, but it seems they do not cope with each other well.

Gradle plugin version: 2.2.0-alpha5

in my module build.gradle I added:

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

And the error message is:

Error:Execution failed for task ':app:transformJackWithJackForDebug'.
java.lang.AssertionError: java.lang.IllegalArgumentException

Did I miss something or it's just they are not compatible?

Octopod answered 13/7, 2016 at 3:41 Comment(1)
Up vote just because the question title is great!!!Heronry
P
6

Version 8.3.0 has just recently been released with support for Jack.

compile 'com.jakewharton:butterknife:8.3.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.3.0'
Pepsinate answered 26/8, 2016 at 1:29 Comment(0)
H
3

Try remove apply plugin: 'android-apt' in your app gradle.

As in the readme, it says:

Note: If you are using the new Jack compiler with version 2.2.0 or newer you do not need the 'android-apt' plugin and can instead replace apt with annotationProcessor when declaring the compiler dependency.

Hiroshima answered 13/7, 2016 at 5:7 Comment(2)
No, I did never add the android-apt plugin.Octopod
this could help you github.com/JakeWharton/butterknife/issues/616Hepcat
O
3

Thanks to @isnotmenow 's tip, I tried to change ButterKnife version to 8.1.0 and it works well. But both 8.2.0 and 8.2.1 complain exceptions, I have post an an issue on the project page.

Octopod answered 13/7, 2016 at 5:52 Comment(1)
for me it works too is downgrade version of the ButterKnife to 8.1.0Cordwainer
T
3

Here's a Jake Wharton's answer from similar StackOverflow post:

If you are using Jack:

  • Omit the 'android-apt' plugin completely.
  • Use annotationProcessor for the dependency (instead of apt).

I believe you have to be using version 2.2.0 of the Android Gradle plugin though instead of 2.1.x (currently the latest is 2.2.0-alpha5).

The Butter Knife documentation will be updated for the next release (8.2.0) to include this information.

From: Butterknife 8.1.0 not working with JDK 1.8 in Android Studio 2.1.2

Check also: http://github.com/JakeWharton/butterknife/issues/616

Hope it will help

Turban answered 17/8, 2016 at 23:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.