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)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With