Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force gradle build failure on deprecated usage

I'm using Android Studio 1.5.1. I'd like to receive a build failure if a deprecated API is used. Currently I change the error level in the settings but the build gives me just a warning. I tried to put in gradle file:

lintOptions {
    abortOnError true
}

but it doesn't work. Is there any code I can use in the gradle file or any option?

like image 397
greywolf82 Avatar asked Oct 31 '22 08:10

greywolf82


1 Answers

In your root build.gradle, try:

allprojects {
    tasks.withType(JavaCompile) {
        options.deprecation = true
        options.compilerArgs += ['-Werror']
    }
}

Works for me on Android Studio 2.2.

like image 157
Xargs Avatar answered Nov 15 '22 05:11

Xargs