user1542447 user1542447 - 6 months ago 49
Android Question

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

Recent after update Android Studio (2.0.7) (maybe this is the cause) sometimes when building i get that error.

Idea is that usually compilation goes well but sometimes i get dagger error.

Is possible that is problem in Dagger configuration?

Error itself:


Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComDaimajiaSwipelayoutLibrary120Library UP-TO-DATE
:app:prepareComF2prateekRxPreferencesRxPreferences101Library UP-TO-DATE
:app:prepareComGithubAakiraExpandableLayout141Library UP-TO-DATE
:app:prepareComGithubAfollestadMaterialDialogsCore0842Library UP-TO-DATE
:app:prepareComGithubCastorflexSmoothprogressbarLibraryCircular120Library UP-TO-DATE
:app:prepareComJakewhartonRxbindingRxbinding030Library UP-TO-DATE
:app:prepareComPnikosisMaterialishProgress17Library UP-TO-DATE
:app:prepareComTrelloRxlifecycle040Library UP-TO-DATE
:app:prepareComTrelloRxlifecycleComponents040Library UP-TO-DATE
:app:prepareComWdullaerMaterialdatetimepicker211Library UP-TO-DATE
:app:prepareIoReactivexRxandroid110Library UP-TO-DATE
:app:prepareMeRelexCircleindicator116Library UP-TO-DATE
:app:prepareMeZhanghaiAndroidMaterialprogressbarLibrary114Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac
/home/ungvas/AndroidDev/Projects/FW/paynet-android/app/src/main/java/md/fusionworks/paynet/ui/activity/BaseActivity.java:23: error: cannot find symbol
import md.fusionworks.paynet.di.component.DaggerActivityComponent;
^
symbol: class DaggerActivityComponent
location: package md.fusionworks.paynet.di.component
/home/ungvas/AndroidDev/Projects/FW/paynet-android/app/src/main/java/md/fusionworks/paynet/PaynetApplication.java:7: error: cannot find symbol
import md.fusionworks.paynet.di.component.DaggerApplicationComponent;
^
symbol: class DaggerApplicationComponent
location: package md.fusionworks.paynet.di.component
2 errors

Incremental compilation of 66 classes completed in 3.719 secs.
:app:compileDebugJavaWithJavac FAILED
:app:compileRetrolambdaDebug

FAILURE: Build failed with an exception.


  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.


    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.



BUILD FAILED

Total time: 19.556 secs


Thanks.

Answer

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
}