简体   繁体   English

Android上的Dagger 2,错过了错误消息

[英]Dagger 2 on Android, missing error messages

I'm using Dagger 2 in my Android project and I'm having trouble debugging it. 我在我的Android项目中使用Dagger 2,但我在调试时遇到问题。 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. 我知道编译失败是因为我的匕首2设置中的错误(以前有过)但是几乎不可能跟踪它,因为我没有得到正确的错误消息告诉我问题出在哪里。 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. 我正在使用Dagger 2.5,Gradle插件2.1.2和android-apt 1.8。

Thanks for your help! 谢谢你的帮助!

Java Java的

javac by default will only show up to 100 errors. 默认情况下, javac最多只能显示100个错误。 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 : 将其添加到您的应用的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 ,可以在使用kapt时启用相同的javac选项。

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

This is currently ignored, but will be fixed in Kotlin v1.2.20 . 这是目前被忽略,但会被固定在科特林v1.2.20

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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