0

I use lint to check an Android app project:

gradlew lint

It shows the following:

> Task :app:compileOfficialDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

The process generates two files: lint-results.html and lint-results.xml. I checked both files, but could not find any information related to deprecated API. Is it possible to generate more details about deprecated API in these two files?

paulsm4
  • 114,292
  • 17
  • 138
  • 190
Hong
  • 17,643
  • 21
  • 81
  • 142

1 Answers1

1

Here's an example "build.gradle" I marked up:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        multiDexEnabled true
        applicationId "com.boxpik.android"
        minSdkVersion 17
        targetSdkVersion 19
    ...
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:all"
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
...

In this example, I added options.compilerArgs << "-Xlint:all" to build.gradle.

This gave me a bunch of Lint warning in my Android Studio "Build" window:

                          ^
C:\xyz\PoolToScoreDetailFragment.java:55: warning: [deprecation] ProgressDialog in android.app has been deprecated
    private ProgressDialog pDialog;
            ^
C:\xyz\PoolToScoreDetailFragment.java:346: warning: [deprecation] ProgressDialog in android.app has been deprecated
            pDialog = new ProgressDialog(application);
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Thank you for your answer. It works for showing the details for my project. I was thinking about using "gradlew lint" as plan A, and it could not work I would go to the project building route as plan B. I will accept your answer if no answer isprovided for using "gradlew lint". This is because I need these details only occasionally. – Hong Nov 15 '19 at 00:47
  • 1
    "Lint" and the "Java Compiler" are separate tools. Both can be run from Gradle. "-Xlint" is a Java compiler command line option. It's the guy who gives you the "detailed messages". I'm not saying you *can't* run both tools from the same Gradle task, but from my perspective it's easier just to add `options.compilerArgs << "-Xlint:all"` to build.gradle when I want it, and comment it out when I don't. – paulsm4 Nov 15 '19 at 01:17
  • Thank you for the elucidation. I did not know they are two different things. This also explains why AS's code analysis does not show the deprecated APIs which made me scratch my head a moment ago. – Hong Nov 15 '19 at 01:26