【问题标题】:lint.xml file is not working for UnusedImport and RedundantSemicolon names in Android Studiolint.xml 文件不适用于 Android Studio 中的 UnusedImport 和 RedundantSemicolon 名称
【发布时间】:2022-09-29 20:06:25
【问题描述】:

我在项目的根目录下创建了一个lint.xml 文件,但 Android Studio 没有将那里定义的规则应用于我的源代码。

实际上,我需要两个存在于 Android Studio 检查中的规则(File -> Settings... -> Editor -> Inspections):

  1. 未使用的导入指令
  2. 冗余分号

    Kotlin -> Redundant constructs

    我分别使用 UnusedImportRedundantSemicolon 名称生成警告和 @Suppress 它们,并且它工作正常。

    当我决定在lint.xml 文件中配置上述操作时,问题就出现了。为此,我在项目的根目录中创建了这个文件,如下所示。

    <?xml version=\"1.0\" encoding=\"utf-8\"?>
    <lint>
        <issue id=\"UnusedImport\" severity=\"error\" />
        <issue id=\"RedundantSemicolon\" severity=\"error\" />
    </lint>
    

    并以这种方式将它与我的build.gradle 文件中的 lint 扩展名链接起来

    lint {
        lintConfig = rootProject.file(\"lint.xml\")
    }
    

    你可以猜到它没有工作,我不知道为什么?

    无论如何感谢您的帮助。

    标签: android android-studio lint


    【解决方案1】:

    在您的情况下,您使用的是不存在的 lint issue id。

    找出所有可能的 lint 问题 ID 的方法已回答 here

    【讨论】:

      猜你喜欢
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      • 2020-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多