构造函数注入找不到符号方法注入成员

天光:

我正在开发具有匕首依赖项的Android应用程序。通过构造函数注入来注入类时,会抛出一个找不到符号的错误。如果我通过@Provides模块内部定义方法提供依赖关系,则一切正常。

代码:

  public class SixthGenericTest {

        @Inject
        FirstTest firstTest;

        @Inject
        public SixthGenericTest()
        {
            Injection.create().getAppComponent().inject(this);
        }
        public String getData(){
            return firstTest.getTestName();
        }
    }

    @Singleton
    @Component(modules = {FirstModule.class})
    public interface AppComponent {
        void inject(SixthGenericTest sixthGenericTest);

    }

和我得到的错误:

错误:(19、28)错误:找不到符号方法injectMembers(MembersInjector,SixthGenericTest)

Pablo Cegarra:

升级您的匕首版本

dependencies {
  compile 'com.google.dagger:dagger:2.x'
  annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
}

在这里检查最新版本

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章