简体   繁体   中英

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM