如何将 -Xlint:unchecked 添加到我的基于 Android Gradle 的项目中? [英] How to add -Xlint:unchecked to my Android Gradle based project?

查看:26
本文介绍了如何将 -Xlint:unchecked 添加到我的基于 Android Gradle 的项目中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将以下内容添加到根 build.gradle 文件中:

I tried to add the following to the root build.gradle file:

subprojects {
    gradle.projectsEvaluated {
        tasks.withType(Compile) {
            options.compilerArgs << "-Xlint:unchecked -Xlint:deprecation"
        }
    }
}

但我明白了:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Libraries:ActionBarSherlock:compileRelease'.
> invalid flag: -Xlint:unchecked -Xlint:deprecation

我做错了什么?

推荐答案

这对我有用:(在你项目的 build.gradle 中)

This is what worked for me: (in your project's build.gradle)

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

这篇关于如何将 -Xlint:unchecked 添加到我的基于 Android Gradle 的项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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