Dagger 2, sometimes on compiling I get "cannot find symbol class DaggerApplicationComponent" Dagger 2, sometimes on compiling I get "cannot find symbol class DaggerApplicationComponent" android android

Dagger 2, sometimes on compiling I get "cannot find symbol class DaggerApplicationComponent"


It's seems that it have something to do with incremental compilation added in Gradle 2.10

I managed to fix it adding the following command to gradle:

-Pandroid.incrementalJavaCompile=false

You can add it in Android Studio in: File | Settings | Build, Execution, Deployment | Compiler adding it as a Command line option.

edit as of 2.0.0-beta3 the plugin gives a warning telling you that this option has been added to the Gradle DSL:

android {    compileOptions.incremental = false}


Changes in 2017:

Android Studio Canary uses a newer version of Gradle and apt plugins may not work, replaced by annotationProcessor. It may fail despite the compiler warning saying that it will be removed in a future version of gradle.

Change this dependency line:

apt 'com.google.dagger:dagger-compiler:2.7'

to

annotationProcessor 'com.google.dagger:dagger-compiler:2.7'

and remove the apt plugin.


You need to update your version 2.11 for dagger.

Your build.gradle's dependencies block should looks like following.

dependencies {    // Other dependencies should go here    compile "com.google.dagger:dagger:2.11"    annotationProcessor "com.google.dagger:dagger-compiler:2.11"    provided 'javax.annotation:jsr250-api:1.0'    compile 'javax.inject:javax.inject:1'}

Hope this helps.