Android Studio lint_baseline.xml 不排除很多它应该解决的问题

Android Studio lint_baseline.xml does not exclude many issues that it should

我的build.gradle里有这个:

android {
  lintOptions {
    abortOnError false
    absolutePaths false
    lintConfig file('lint.xml')
    baseline file('lint-baseline.xml')
  }
}

我之前已经 运行 Analyze > Inspect Code 建立了这个基线。我还确认该文件确实存在,并且包含要忽略的问题。

然而,当我 运行 Analyze > Inspect Code 时,仍然有很多警告出现。似乎没有根据基线排除的问题是那些lint --list没有列出的/列出的那些here

它们包括'Unused declaration'、'Field can be local'等

有什么方法可以过滤掉这些吗?为什么代码检查会检查 lint 未列为问题的 warnings/errors?

来自Android工作室视察:

Lint can be configured with a "baseline"; a set of current issues found in a codebase, which future runs of lint will silently ignore. Only new issues not found in the baseline are reported.

Note that while opening files in the IDE, baseline issues are not filtered out; the purpose of baselines is to allow you to get started using lint and break the build on all newly introduced errors, without having to go back and fix the entire codebase up front. However, when you open up existing files you still want to be aware of and fix issues as you come across them.

This issue type is used to emit two types of informational messages in reports: first, whether any issues were filtered out so you don't have a false sense of security if you forgot that you've checked in a baseline file, and second, whether any issues in the baseline file appear to have been fixed such that you can stop filtering them out and get warned if the issues are re-introduced.

我也在想同样的事情。也许这将有助于解释事情。

基线功能旨在隐藏控制台中的 linting 错误并使其成为 new warnings/errors 将破坏构建。不幸的是,这不会抑制 Android 工作室检查。