【问题标题】:Android lint is ignoring my lint.xml, skipping checks I am trying to enableAndroid lint 忽略了我的 lint.xml,跳过了我尝试启用的检查
【发布时间】:2015-08-06 19:01:23
【问题描述】:

我正在尝试使用 Android lint 检查有关我的项目的一些内容。它似乎忽略了我提供的 lint.xml 文件,使我无法启用检查。

我在 Ubuntu 14.04 上使用 Android Studio,但我只是从命令行调用 ~/Android/Sdk/tools/lint。

我在做:

 $ lint --config GF/lint.xml --html lintCheck.html GF   
 Scanning 7.5.0: .
 Scanning 7.5.0 (Phase 2): 
 ... (and so on) ...
 Wrote HTML report to file:/home/ray/Projects/jj/lintCheck.html
 Lint found 26 errors and 198 warnings
 $ 

报告列出了所有未启用的检查。这是我创建的 GF/lint.xml 文件:

 $ cat GF/lint.xml 
 <?xml version="1.0" encoding="UTF-8"?>
 <lint>
     <issue id="HardcodedText" severity="error" />
 </lint>
 $

以下是我尝试调用 lint 的方法。在所有这些情况下,所有检查都会显示如下内容:

 RelativeOverlap
 Disabled By: Project lint.xml file

那么,它所指的项目 lint.xml 文件在哪里?我在 ~/Android 和我的所有项目中都进行了搜索,但该文件没有出现在其他任何地方。

相对重叠 禁用者:项目 lint.xml 文件

我尝试过的:

 $ lint  --ignore MissingTranslation -Wall --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable all --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable Correctness,Security,Performance,Usability --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable Correctness --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable RelativeOverlap --html lintCheck.html GF
 $ lint --enable RelativeOverlap --html lintCheck.html GF
 $ lint --config GF/lint.xml --html lintCheck.html GF
 $ lint --config GF/lint.xml --html lintCheck.html GF

任何建议将不胜感激。

【问题讨论】:

  • lint.xml在什么目录下? (即“GF”文件夹在哪里)?我在与srclibsbuildgradle 文件夹相同的目录中有一个 lint.xml 文件,当我从命令行运行 lint 时它会被拾取。
  • 另外,通过 gradle 运行 lint 有什么不同吗? (即./gradle lint
  • 我应该安装命令行版本的 gradle 来试试这个吗?我通过使用 Android Studio 来使用 gradle,而不是在命令行上。
  • GF 目录是我的项目根目录,其中我的 src、lib、gradle 目录等等。
  • 尝试将lint.xml 文件放在一个目录上 - 即与GF 所在的目录相同,而不是在GF 文件夹中。

标签: android lint


【解决方案1】:

在 gradle 文件中配置 lint-options 以便提取 lint.xml

lintOptions {
        // set to true to turn off analysis progress reporting by lint
        quiet true
        // if true, stop the gradle build if errors are found
        abortOnError false
        // do not ignore warnings
        warningsAsErrors true
        lintConfig file('lint.xml')
    }

只需将上面的 lintoptions 放到 app 文件夹的 build.gradle 文件中

并将 lint.xml 文件放在 app 文件夹中,然后它就会被拾取

这是在工作室目录中放置的截图:

【讨论】:

    猜你喜欢
    • 2020-06-04
    • 2011-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 2011-12-22
    • 2017-12-09
    相关资源
    最近更新 更多