Recompile with -Xlint in Android studio

Solution 1:

The message suggest you recompile with args -Xlint to get more warning details, add these code to build.gradle:

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
    }
}

Then you can fix warnings by detailed messages.
For example, you can replace deprecated method with new method(there always been a new method since old method has been deprecated) .

However, sometimes we don't want change our code for some reasons, we just want get rid of compile warning, you can add @SuppressWarnings("deprecation") in front of the deprecated method.

Solution 2:

You need to add the following inside your app level buld.graddle file

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
    }
}

If for some reasons you need to continue using a deprecated API you can just suppress the warning. You could annotate the deprecated method with the

@SuppressWarnings("deprecation")

annotation.

post link

Solution 3:

If you are facing issue in generating signed apk, you can try to do this in your build.gradle(app)

android {
    lintOptions {
        checkReleaseBuilds false
    }
}

Solution 4:

It is some error in the project, maybe from XML files. Disabling lintOptions is not a correct solution. Find the error and fix the problem, to do this run below command in Android Studio Terminal

Windows

gradlew assembleDebug --stacktrace

MAC

./gradlew assembleDebug --stacktrace