Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recompile with -Xlint in Android studio

When I build my Android project in Android Studio, I get message:

Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 

and

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

I would like to do what the message suggested, but how? How can I configure my Android studio to re-compile my project with -Xlint as the above message suggested? (I am using Android Studio 3.0.1)

like image 950
Leem Avatar asked Dec 10 '17 16:12

Leem


People also ask

How do I sync gradle with Android Studio?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.


1 Answers

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.

like image 171
y4n9b0 Avatar answered Oct 02 '22 10:10

y4n9b0