不推荐使用的情况下强制gradle生成失败 [英] Force gradle build failure on deprecated usage

查看:139
本文介绍了不推荐使用的情况下强制gradle生成失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 1.5.1。如果使用已弃用的API,我希望收到构建失败。目前,我在设置中更改错误级别,但构建仅给出警告。

  lintOptions {
abortOnError true
}

但它不起作用。有没有我可以在gradle文件或任何选项中使用的代码?在你的根目录 build中有 .gradle ,试试:

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

适用于Android Studio 2.2。


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?

解决方案

In your root build.gradle, try:

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

Works for me on Android Studio 2.2.

这篇关于不推荐使用的情况下强制gradle生成失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆