为什么在管道上运行 Android Lint 会给出不同的警告?

时间:2021-05-14 17:31:59

标签: android lint android-lint

我已经在我的 app 模块上启用了带有这些启用规则的 config xml 的 Android Lint,并且还创建了一个基线。

lintOptions {
        checkReleaseBuilds false
        abortOnError true
        ignoreTestSources true
        lintConfig rootProject.file('config/lint.xml')
        baseline file("${project.projectDir}/baselines/android-lint-baseline-${getCurrentFlavor()}.xml")
}
<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="FindViewByIdCast" severity="error" />
    <issue id="MissingSuperCall" severity="error" />
    <issue id="UsesMinSdkAttributes" severity="error" />
    <issue id="AaptCrash" severity="error" />
    <issue id="GradleCompatible" severity="error" />
    <issue id="HardcodedText" severity="error" />
    <issue id="RestrictedApi" severity="error" />

</lint>

当我通过 gradle lintDebug 任务在本地运行它时,显然它不会检查 RestrictedApi 规则,它不会在基线上注册任何 RestrictedApi 事件或在控制台上发出警告.但是当我在管道上运行它时,使用相同的任务,我收到以下 lint 错误:

Error: Fragment.getLayoutInflater can only be called from within the same library group prefix (referenced groupId=androidx.fragment with prefix androidx from groupId=android) [RestrictedApi]
              LayoutInflater layoutInflater = getLayoutInflater(null);

如果我在 IDE 上运行 Code > Run Inspection By Name > Restricted Api,它将在发布目标上运行并会发现这种情况。

我可以检查哪些可能性?为什么 lintDebuglintRelease 给出不同的结果?

提前致谢<3

0 个答案:

没有答案
相关问题