greywolf82
greywolf82

Reputation: 22183

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?

Upvotes: 5

Views: 3376

Answers (1)

Xargs
Xargs

Reputation: 779

In your root build.gradle, try:

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

Works for me on Android Studio 2.2.

Upvotes: 2

Related Questions