Closed Khaos116 closed 7 years ago
经测试,使用com.neenbedankt.android-apt这个插件必然导致 butterknife8.4.0空指针; 可以使用低版本的butterknife避免这个问题,但是如果使用了dagger2.2可能会出现编译问题(改为dagger2.0.2即可)
+1
do you have "apt 'com.jakewharton:butterknife-compiler:8.4.0'" in your dependencies ?
@vzeitler @caiyoufei +1,经测试,在引用android-apt的情况下,将com.jakewharton:butterknife-compiler:8.4.0的annotationProcessor前缀改为apt可以正常工作
@caiyoufei see thie blog:
http://www.jianshu.com/p/268c14130bea
We all see, the two libs recommand using annotationProcessor
dependencies { compile 'com.jakewharton:butterknife:8.4.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' }
use apt replace of annotationProcessor! use apt replace of annotationProcessor! use apt replace of annotationProcessor!
Replacing annotationProcessor for apt as @CaoyangLee mentioned worked for my project.
This is how I got both to work together:
// Butter Knife
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
// Dagger 2
apt 'com.google.dagger:dagger-compiler:2.8'
compile 'com.google.dagger:dagger:2.8'
provided 'javax.annotation:jsr250-api:1.0'
Thanks @Emeritus-DarranKelinske
@caiyoufei dagger2 都2.8了 我用的2.8没发现有这个问题哦
@renhuihhh 参考 Emeritus-DarranKelinske 给出的答案
The option that @Emeritus-DarranKelinske provided doesn't seem to work when you are using ButterKnife inside a library by applying the plugin
apply plugin: 'com.jakewharton.butterknife'
My best guess would be because of the reference to the support annotation processor in the plugin instead of referencing APT, is this likely?
public final class FinalRClassBuilder {
private static final String SUPPORT_ANNOTATION_PACKAGE = "android.support.annotation";
My thoughts on this are that no action is needed as Dagger 2 should be playing nicely with annotationProcessor
instead of relying on apt (deprecated as of Gradle Android plugin 2.2).
Because dagger2 need use apply plugin: 'com.neenbedankt.android-apt',so butterknife8.4.0 is always NullPointException