如何使用-Xlint:deprecation重新编译 [英] How to recompile with -Xlint:deprecation

查看:1398
本文介绍了如何使用-Xlint:deprecation重新编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不使用Android Studio,但我使用build.gradle从命令行构建所有内容.我生成这样的Lint报告:

I don't use Android Studio but I build everything from the command line using build.gradle. I generate a Lint report like this:

./gradlew lint

这可以正确生成Lint报告,但它也显示以下内容:

This correctly generates a Lint report but it also says this:

Note: MyActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

这让我想知道我该怎么做?我尝试了以下方法:

This makes me wonder how I can do that? I've tried the following:

./gradlew lint -Xlint:deprecation

但是它不起作用.它说:

But it doesn't work. It says:

Problem configuring task :app:lint from command line.
Unknown command-line option '-X'.

那么如何通过gradle将-Xlint:deprecation传递给Lint?

So how can I pass -Xlint:deprecation to Lint via gradle?

推荐答案

要回答我自己的问题,您需要在项目级build.gradle文件中添加以下内容:

To answer my own question, you need to add the following to your project-level build.gradle file:

allprojects {
    ...

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

这篇关于如何使用-Xlint:deprecation重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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