I'm putting the following at the end of my project gradle file:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs +=
['-Xep:MissingOverride:ERROR',
'-Xep:MissingCasesInEnumSwitch:ERROR',]
}
}
However, in my code if I remove an @Override annotation somewhere or remove a switch statement, my Android project still builds. Shouldn't it fail with an error?
asked Feb 16, 2017 at 13:50
ADev
5,5192 gold badges19 silver badges30 bronze badges
1 Answer 1
I googled your problem and found this post that described your problem and the solution looks like this:
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
As is seems the gradle build is different for android projects than for java projects and you can't access the task CompileJava itself as stated in my first comment.
Sign up to request clarification or add additional context in comments.
1 Comment
Danny E.K. van der Kolk
Sir, I salute you. This was a pain, and you solved it! I wonder why Android Studio does not have a clear option for that in the project settings. Anyway, thanks!
Explore related questions
See similar questions with these tags.
lang-java
compileJava{ options.fork = true options.forkOptions.executable = 'javac' options.compilerArgs.addAll( [ '-APackageAcronym='+gradle.ext.packageAcronym, '-s', gradle.ext.generatedQueriesDir ] ) }since compileJava is it's own task.compileJavaat the root level? If I do so in my case I get the following error message: "Error: Could not find method compileJava() ..."allprojects { gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } } }found here: stackoverflow.com/questions/18689365/… information for compileJava task: stackoverflow.com/questions/16853130/…