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.
class DiTutorialApplication : Application() { // DaggerApplicationComponent is the implementation of ApplicationComponent provided by Dagger val appComponent = DaggerApplicationComponent. create() } To validate our setup, we can log a call to the brew() function of the CoffeeMaker on the creation if the application.
HasActivityInjector is a part of dagger. android . You can but not have to use it. You can easily live without this thing and still use everything that dagger offers. That's why it is in some guides but not all of them.
The cannot find symbol error, also found under the names of symbol not found and cannot resolve symbol , is a Java compile-time error which emerges whenever there is an identifier in the source code which the compiler is unable to work out what it refers to.
Dagger generates code similar to what you would have written manually. Internally, Dagger creates a graph of objects that it can reference to find the way to provide an instance of a class. For every class in the graph, Dagger generates a factory-type class that it uses internally to get instances of that type.
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 }
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With