使用 android studio 项目在命令行上使用 Gradle 构建失败:Xlint 错误 [英] Failure on build with Gradle on command line with an android studio project : Xlint error

查看:28
本文介绍了使用 android studio 项目在命令行上使用 Gradle 构建失败:Xlint 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用此命令使用 gradle 构建 android 项目时:

When I try to build an android project with gradle with this command :

> gradlew clean build assembleRelease

它给了我这个错误:

Note: Some input files use or override a deprecated API.  
Note: Recompile with -Xlint:deprecation for details.  
Note: Some input files use unchecked or unsafe operations.  
Note: Recompile with -Xlint:unchecked for details.

我可以构建这个项目并在 Studio 中制作 APK.

I can build this project and make the APK in Studio.

有没有办法配置 Gradle 来进行编译而忽略 Xlint 通知?

Is there a way to configure Gradle to make a compilation ignoring Xlint notifications ?

或者,我可以使用其他参数,通过 gradle/gradlew 从命令行发布吗?

OR, can I use other parameters, to make the release from command-line with gradle/gradlew ?

推荐答案

这是一个很好的警告,而不是错误.要查看完整的 lint 报告,您可以将这些行添加到 build.gradle:

It's a nice warning, not an error. To see the complete lint report you can add these lines to build.gradle:

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

如果你真的想摆脱这些警告:

If you really want to get rid of those warnings:

  1. 不要使用已弃用的 API
  2. 使用@SuppressWarnings("deprecation")

这篇关于使用 android studio 项目在命令行上使用 Gradle 构建失败:Xlint 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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