Dagger 2 component not generated

前端 未结 12 1557
走了就别回头了
走了就别回头了 2021-01-31 07:21

In my module, in my base Application class

component = DaggerCompClassComponent.builder()
                .classModule(new ModuleClass()).build();
12条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 07:57

    If you have several modules in your AndroidStudio (modules in terms of Android Studio, not Dagger), another possible reason of fail is that you've forgot to put annotation processors into the all modules' build.gradle.

    We've divided our app into several modules, updated dependencies from using implementation to using api but forgot to handle annotation processors accordingly.

    So, you can have this lines only in a root module:

    api 'com.google.dagger:dagger-android:2.16'
    // if you use the support libraries
    api 'com.google.dagger:dagger-android-support:2.16'
    

    But this ones should be specified in all modules dependencies:

    annotationProcessor 'com.google.dagger:dagger-compiler:2.16'
    // if you use injections to Android classes
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.16'
    

提交回复
热议问题