# Recompile with -Xlint in Android Studio

*2018-11-09*

> Enable detailed Java compiler warnings in Android Studio by adding -Xlint:unchecked and -Xlint:deprecation to Gradle’s JavaCompile tasks.

Avoiding deprecated APIs is a good habit. Plus, clean build output is always nice :)

When you build an app, the Java compiler may report that some input files use unchecked or unsafe operations, or use or override a deprecated API:

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

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

As the messages suggest, we can recompile with `-Xlint:unchecked` and `-Xlint:deprecation` to get more details about these warnings.

Open the app module's `build.gradle` file:

{{< figure align="aligncenter" width=474 src="/wp-content/uploads/2018/11/Screenshot-2018-11-08-at-14.40.54.png" alt="App module's build.gradle file" caption="App module's build.gradle file" >}}

Add an `allprojects {}` block if one isn't already present. Inside it, configure Gradle to pass the following compiler arguments to each `JavaCompile` task:

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

Now, each time we build the app, we'll see details about unchecked or unsafe operations and deprecated APIs used in our code.

Tip: If you need to keep using a deprecated API, you can suppress its deprecation warnings by adding the following annotation to the method that uses it:

```java
@SuppressWarnings("deprecation")
```

