简体   繁体   English

在Android Studio中找不到Dagger

[英]Dagger not found in Android Studio

When running my program from AS, I usually get this error: 从AS运行程序时,通常会出现以下错误:

error: cannot find symbol class DaggerActivityComponent 错误:找不到符号类DaggerActivityComponent

I've tried the remedies suggested at Cannot find symbol class "Generated" for Dagger 2 , but the problem continues. 我已经尝试过在Dagger 2找不到符号类“ Generated”时建议的补救措施,但是问题仍然存在。 I can get around the error by doing clean and rebuild before run. 我可以通过在运行之前进行清理和重建来解决该错误。 This is a pain, of course. 当然,这很痛苦。 I don't see a pattern for when the error does not occur. 没有出现错误时,我看不到任何模式。

I'm using Dagger version 2.0.2 我正在使用Dagger 2.0.2版

In build.gradle, I've made the suggested changes: (I was unable to use SNAPSHOT-2.1 version of Dagger) 在build.gradle中,我进行了建议的更改:(我无法使用SNAPSHOT-2.1版本的Dagger)

//Required by Dagger2
compile 'org.glassfish:javax.annotation:10.0-b28'
// Alternate to above as
// provided 'javax.annotation:jsr250-api:1.0'
compile "com.google.dagger:dagger:$DAGGER_VERSION"

The other members on my team are not experiencing this, so I suspect it might be related to my configuration for Android Studio. 我团队中的其他成员没有遇到这种情况,因此我怀疑这可能与我对Android Studio的配置有关。

Thank you for any further ideas. 感谢您提出任何其他建议。

there must be some error in your using of @Inject annotations. 使用@Inject批注时一定有一些错误。 if you have done everything correct, you can try 'Build -> Clean Project' and then 'Build -> Make Project'.. It works for me. 如果您已正确完成所有操作,则可以尝试“构建->清理项目”,然后尝试“构建->创建项目”。

一次偶然的机会,当出现此错误时,我尝试再次点击<Run>按钮,结果发现该问题可以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM