我刚开始使用 Dagger 2 进行依赖注入。当我启动模块,组件并尝试构建我的应用程序时, gradle 抛出错误
I just started doing dependency injection using Dagger 2. When I spun up my modules, components and tried to build my application, gradle threw the error
错误:(4,24)错误:找不到符号类生成
我挖到它并发现错误是在其中一个类 Dagger 生成 DI 。缺少的特定类是 javax.annotation.Generated ,抛出错误的行是一行代表 Dagger 生成的类为 @Generated(dagger.internal.codegen.ComponentProcessor)
I dug into it and found that the error is in one of the classes Dagger generates to do DI. The particular class that's missing was javax.annotation.Generated and the line throwing the error is the line that anntotates a Dagger generated class as @Generated("dagger.internal.codegen.ComponentProcessor")
这个问题有助于找到解决方案,即添加 javax 通过将行 compile'org.glassfish:javax.annotation:10.0-b28'添加到我的gradle构建文件中作为依赖包。这导致了一个成功的构建。
This question helped in finding the solution which is to add the javax package as a dependency by adding the line compile 'org.glassfish:javax.annotation:10.0-b28' to my gradle build file. This led to a successful build.
我的问题是,为什么没有添加为 Dagger的传递依赖或者为什么没有其他人遇到这个特殊问题(我假设是这样,因为我在这里找不到任何关于这个的问题?
My question is, why is that not added as a transitive dependency for Dagger or why hasn't anyone else faced this particular issue (I assume so, since I couldn't find any question here regarding this?
推荐答案阅读本文以获取更多信息: github/google/dagger/issues/ 95
Read this for more info: github/google/dagger/issues/95
基本上,解决方案是做你已经完成的工作,包括glassfish javax注释库。
Basically, the solution is to do what you've already done which is include the glassfish javax annotation library.
更多推荐
找不到符号类“生成”为匕首2
发布评论