匕首2“ Dagger”前缀组件无法编译?自动生成的类 [英] Dagger 2 "Dagger" prefix component not able to compile? auto generated class

查看:106
本文介绍了匕首2“ Dagger”前缀组件无法编译?自动生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Android上使用Dagger 2。我以前有它工作,我有一个appModule将依赖项注入到应用程序中的特定类中。我的问题是iam遇到错误

Im trying to use Dagger 2 on android. I previously had it working and i had an appModule injecting dependencies into specific classes in the app. My Issue is that iam getting the error

Error:(14, 55) error: cannot find symbol class DaggerAppComponent

试图导入。这是一个自动生成的类

which attempting to import. this is an autogenerated class

以下是我的build.gradle文件中Dagger特定的依赖项

below are my Dagger specific dependencies in my build.gradle file

 compile 'com.google.dagger:dagger-compiler:2.0.2'
 compile 'com.google.dagger:dagger:2.0.2'
 provided 'javax.annotation:jsr250-api:1.0'

我已经尝试了多次清洁和重建应用程序,但不会生成该类。 Ive还尝试使用

Ive tried cleaning and rebuilding the app numerous times but the class wont generate. Ive also tried using

 compile 'org.glassfish:javax.annotation:10.0-b28'

我的注解,但Iam还是没有运气吗?如果有人可以帮助我,我会很感激。目前我很难确切了解发生了什么?谢谢

for my annotations but Iam having no luck still? If anyone can help me out id appreciate. Its kind of difficult to see exactly what is going on for me at present? Thanks

编辑:组件代码
在此之前工作过,我刚刚添加了1个额外的类来注入?

Component code this was working before and i just added 1 extra class to inject into?

@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {

    void inject(RegHelper reghelper);
    void inject(headerFooterRecViewAdapter headadapter);
    void inject(SectionListExampleActivity seclistactivity);

}


推荐答案

`dependencies{
...
compile 'com.google.dagger:dagger:2.11'
compile 'com.google.dagger:dagger-android-support:2.11'
annotationProcessor "com.google.dagger:dagger-compiler:2.11"
}`

这篇关于匕首2“ Dagger”前缀组件无法编译?自动生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆