butterknife8.3.0和dagger2一起使用抱怨,但是butterknife7。*还可以

时间:2016-08-25 07:40:43

标签: android dagger-2 butterknife

的javascript

Error:E:\Android\myGit\GJBaseFrame\GJBaseFrame\app\src\main\java\com\yubaokang\baseframe\views\activitys\MainActivity.java:9: error: could not find the symbol
Com.yubaokang.baseframe.dagger.component.DaggerMainActivityComponent import;
^
Symbol: class DaggerMainActivityComponent
Location: package com.yubaokang.baseframe.dagger.component
E:\Android\myGit\GJBaseFrame\GJBaseFrame\app\src\main\java\com\yubaokang\baseframe\views\activitys\SecondActivity.java:9: error: could not find the symbol
Com.yubaokang.baseframe.dagger.component.DaggerSecondActivityComponent import;
^
Symbol: class DaggerSecondActivityComponent
Location: package com.yubaokang.baseframe.dagger.component
E:\Android\myGit\GJBaseFrame\GJBaseFrame\app\src\main\java\com\yubaokang\baseframe\views\App.java:6: error: could not find the symbol
Com.yubaokang.baseframe.dagger.component.DaggerAppComponent import;
^
Symbol: class DaggerAppComponent
Location: package com.yubaokang.baseframe.dagger.component
Error: service configuration file is not correct, or structural processing program object javax.annotation.processing.Processor: provider butterknife.compiler.ButterKnifeProcessor could not be instantiated: java.lang.NoSuchMethodError: com.squareup.javapoet.CodeBlock.of (Ljava/lang/String; [Ljava/lang/Object;) Lcom/squareup/javapoet/CodeBlock; thrown exception error
Build failed with an exception. FAILURE:
* went wrong: What
Failed for task Execution ': app:compileDebugJavaWithJavac'.
  

看不见;编译器错误输出以获取详细信息汇编   *尝试:   使用--stacktrace Run选项获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。此处的图像描述

``` click open error image

2 个答案:

答案 0 :(得分:0)

1



compile 'com.google.dagger:dagger:2.5'
provided 'com.google.dagger:dagger-compiler:2.5'// modify apt to provided




2.in app / build.gradle add



packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}




在android {}

参考http://www.cnblogs.com/yizuochengchi2012/p/5659362.html

答案 1 :(得分:0)

请同时检查匕首和butterknif版本。

例如:

黄油刀应该是这样的。

implementation 'com.jakewharton:butterknife:8.7.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'

匕首应该是这样的。

annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
implementation 'com.google.dagger:dagger:2.9'