I don\'t use Android Studio but I build everything from the command line using build.gradle
. I generate a Lint report like this:
./gradlew lint
This is an accepted answer but solved this with Gradle Java plugin as below.
Add java plugin to build.gradle
file if not added already.
plugins {
// Apply the java plugin to add support for Java
id "java"
}
Then add task compileJava and/or compileTestJava
based on your need to check deprecations for only java main source code or java test source code.
You can add various compile options as listed here
compileTestJava {
// options.incremental = true
// options.fork = true
// options.failOnError = false
options.compilerArgs.add("-Xlint:deprecation")
}
Also, we can specify for the main and test sourcecode project as
tasks.withType(JavaCompile) {
options.compilerArgs.add("-Xlint:deprecation")
}
Just an update from me since I ran into this issue recently:
You can get the details for this deprecation issue by doing as @Andreas suggested in the accepted answer. If you're using Kotlin, the real solution is (in build.gradle):
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add("-Xlint:deprecation")
}
}
}
One other solution is to update your AndroidSDK. The issue is with an SDK method overriding a deprecated feature. In your build.gradle file you can change the compileSdkVersion:
android {
compileSdkVersion 29 //Change this to the latest release
...
...
defaultConfig {
...
targetSdkVersion 29 //Change this too
...
}
}
Using the latest SDK version will likely fix your issue. Android does a good job of fixing deprecation issue between releases. If it persists, you might just need to wait until the next SDK release. If the issue isn't in the AndroidSDK but instead in a package you've downloaded, you should see if the package needs upgrading or contact the manager of that package.
To answer my own question, you need to add the following to your project-level build.gradle
file:
allprojects {
...
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}
I have added in-app level build.gradle and resolved issue
aaptOptions { cruncherEnabled = false }