【问题标题】:How do I run standalone lint from Android SDK Tools on a Gradle Project如何在 Gradle 项目上从 Android SDK 工具运行独立 lint
【发布时间】:2020-06-02 09:53:10
【问题描述】:

当我尝试运行 Android SDK 命令行工具中提供的lint 工具时,它失败并出现以下错误

build.gradle: Error: "." is a Gradle project. To correctly analyze Gradle projects, you should run "gradlew lint" instead. [LintError]
1 errors, 0 warnings

我的用例要求我在 CI 环境中运行具有特定检查的独立 lint。如何解决此错误?

【问题讨论】:

  • 你运行了什么确切的命令,这给了你这个错误?
  • 没什么,只是lint . :)
  • 你试过在lint app/这样的目录上运行
  • 是的。和res 目录。还有我感兴趣的特定文件。所有文件都以同样的错误告终。

标签: android android-sdk-tools android-lint


【解决方案1】:

我四处寻找文档和答案。 Documentation 没有关于该主题的太多信息。我在发布此问题之前找到了one answer,但针对该错误提供的建议也不起作用。最后,正如切斯特所说的,这甚至都没有关系。

由于我在 CI 环境中运行该工具,因此我最终执行了以下操作

# delete the build.gradle files from the project
find . -type f -name "build.gradle" -exec rm -f {} \;

# run the lint with whatever checks. It works!!
lint --check Whatever .

# stash everything except the deleted files
git add **/*/build.gradle
git stash -k

# stash the deleted files
git stash

# drop the stash with deleted files
git stash drop

# pop the stash with everything else
git stash pop

这是一个肮脏的黑客。始终对更好的解决方案持开放态度!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-13
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多