I updated my project to the latest Android APIs and the project now has multiple deprecated methods. Does Android Studio have a cool way of listing all classes containing said methods, such as the TODO window? I know I can go through every class and search methodically through the code, but I would rather like to make it easy on myself.
3 Answers
If it helps someone else heres the answer to my question:
If you go to Analyze -> Inspect Code...
When your project has been inspected click on Code maturity issues and tada, there is a list of all Deprecated API usages :)
UPDATE: May 2021
Deprecation warnings are now found under your respective language.
Kotlin -> Migration -> Usage of redundant or deprecated syntax or deprecated symbols
Java -> Code maturity
- 2,558
- 3
- 14
- 31
-
6It doesn't show deprecated methods ("Code maturity issues" is not listed). – CoolMind Jan 22 '21 at 15:14
Follow below steps: Go to Analyze -> Run Inspectinon By Name ->type Deprecated API Usage
- 26,829
- 13
- 75
- 94
- 649
- 5
- 2
-
1Please make sure your minSdkVersion value is proper. This tool will show all the deprecated APIs in source code below the minSdkVersion value. – Faisal T Dec 06 '17 at 10:07
Looking at How to recompile with -Xlint:deprecation, add into root build.gradle:
allprojects {
...
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:deprecation"
}
}
}
or in build.gradle.kts:
allprojects {
...
gradle.projectsEvaluated {
tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:deprecation")
}
}
}
Then start in Terminal:
./gradlew lint
or in Gradle menu:
It will show warnings, but also can fail after 3 errors:
Caused by: org.gradle.api.GradleException: Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
android { lintOptions { abortOnError false } }The first 3 errors (out of 4) were:
Adding these lines in app/build.gradle won't help. You should fix all errors and try to launch Lint again.
If you have many errors, you can show all of them:
android {
lintOptions {
// abortOnError false
// if true, stop the gradle build if errors are found
isAbortOnError = false
// if true, show all locations for an error, do not truncate lists, etc.
isShowAll = true
}
}
- 22,602
- 12
- 167
- 196