如何使用-Xlint:deprecation重新编译

问题描述 投票:32回答:2

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

./gradlew lint

这会正确生成Lint报告,但它也会这样说:

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

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

./gradlew lint -Xlint:deprecation

但是它不起作用。它说:

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

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

android gradle lint
2个回答
53
投票

要回答我自己的问题,请将其添加到应用程序目录中的build.gradle

allprojects {
    ...

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

0
投票

我已添加应用内级build.gradle并解决了问题

aaptOptions { cruncherEnabled = false }
© www.soinside.com 2019 - 2024. All rights reserved.