记Dagger2使用过程中的一个BUG--compileGoogleDebugJavaWithJavac

  项目编译可以通过,不过没有生成Dagger2的类,导致无法运行项目。。

错误提示

Error:(14, 41) 错误: 找不到符号
符号:   类 DaggerAppComponent
位置: 程序包 com.codeest.geeknews.di.component

Error:Execution failed for task ':geeknews:compileGoogleDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

在 Terminal 调试:gradlew compileGoogleDebugJavaWithJavac -stacktrace 可以跟踪问题所在具体位置。

我的解决方式把 xxx-compiler 的引入方式都改为:annotationProcessor 。

  改前,不通过:

//di
compile rootProject.ext.dependencies["dagger"]
compile rootProject.ext.dependencies["dagger-compiler"]
compile rootProject.ext.dependencies["butterknife"]
apt rootProject.ext.dependencies["butterknife-compiler"]

  改后,完美运行:

//di
compile rootProject.ext.dependencies["dagger"]
annotationProcessor  rootProject.ext.dependencies["dagger-compiler"]
compile rootProject.ext.dependencies["butterknife"]
annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]

 

annotationProcessor 

猜你喜欢

转载自www.cnblogs.com/jooy/p/9074463.html