且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android-将所有棉绒警告设置为错误(某些警告除外)

更新时间:2021-09-05 22:34:59

如果不使用Gradle lintOptions(checkAllWarningswarningsAsErrors等)进行配置,则应该能够实现所需的功能哪些警告应视为错误.请改用lint.xml.在那里,您可以执行以下操作:

You should be able to achieve what you want if you do not use the Gradle lintOptions (checkAllWarnings, warningsAsErrors, etc.) to configure which warnings should be treated as errors. Use lint.xml instead. There you can do the following:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
   <issue id="MissingTranslation" severity="warning" />

   <!-- The following must be at the bottom of your file!
        All lint issues (not listed above) will be treated as errors. -->
   <issue id="all" severity="error" />
</lint>

在我的测试中,这似乎运行良好,并且所有警告都被视为错误,但lint.xml顶部列出的警告除外. 但是,我尚未将它与lint-baseline.xml结合使用进行测试,但我认为没有理由也不能在这里使用它.

In my tests this seemed to work fine and all warnings were treated as errors except for those listed at the top of the lint.xml. However, I've not tested it in combination with a lint-baseline.xml but I see no reason why it shouldn't work there as well.