Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dagger 2 on Android, missing error messages

I'm using Dagger 2 in my Android project and I'm having trouble debugging it. I know that the compilation fails because of an error in my dagger 2 setup (had it before) but it's almost impossible to track it down because I don't get a proper error message telling me where the problem lies. All I get are messages that show that the annotation processing failed. Along the lines of:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Error:(14, 28) error: cannot find symbol class BR
Error:(17, 40) error: package com.some.package.databinding does not exist
Error:(17, 51) error: cannot find symbol class DaggerSomeComponent
...

Maybe it's somehow related to the fact that I'm also using databinding!?

I'm using Dagger 2.5, Gradle plugin 2.1.2 and android-apt 1.8.

Thanks for your help!

like image 980
fnberta Avatar asked Jun 19 '16 21:06

fnberta


1 Answers

Java

javac by default will only show up to 100 errors. You are probably over this limit because of databinding reporting an error for each binding class it generates.

Add this to your apps's build.gradle:

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xmaxerrs" << "500"
    }
}

Kotlin

You can enable the same javac option when using kapt by adding the following to your build.gradle.

kapt {
    javacOptions {
        option("-Xmaxerrs", 500)
    }
}

This is currently ignored, but will be fixed in Kotlin v1.2.20.

like image 110
Austyn Mahoney Avatar answered Sep 19 '22 21:09

Austyn Mahoney