2013-01-22 84 views
19

几个警告,我知道我可以忽略林特与属性tools:ignore忽略Android的皮棉

规则我的困难是,我想忽略一些规则。 在我的情况下,谷歌分析ga_trackingId,我想忽略TypographyDashesMissingTranslation

我没有成功尝试

<resources tools:ignore="TypographyDashes|MissingTranslation" xmlns:tools="https://schemas.android.com/tools" > 

<resources tools:ignore="TypographyDashes,MissingTranslation" xmlns:tools="https://schemas.android.com/tools" > 

<resources tools:ignore="TypographyDashes MissingTranslation" xmlns:tools="https://schemas.android.com/tools" > 

我现在没有想法。如何在tools:ignore中指定多个值?

+3

根据文件逗号分开,应该这样做。查看此开发者页面的底部; http://developer.android.com/tools/debugging/improving-w-lint.html – harism

+1

感谢指针@harism。我已经打开了[问题43070](http://code.google.com/p/android/issues/detail?id=43070) – rds

+0

@harism良好的命名空间;我想用你接受的答案 – rds

回答

8

这里的问题是错误的命名空间URI的使用在xml资源文件中;

xmlns:tools="https://schemas.android.com/tools" 

本来应该是http://...协议。这在issue 43070

+0

总之:不要按照文档,而是使用'http'命名空间:) – rds

2

用过eclipse还是intelliJ?

在Eclipse中,去窗口 - >首选项 - > Android的 - >皮棉错误检查

enter image description here

而且有一个有趣的;-)

+0

相信你,如果有帮助,谢谢你有效的 – throrin19

+0

它有帮助,但是这个配置没有相同的范围。 – rds

+0

此图像用于说明你将要发生的事情。 – throrin19

26

中有更详细的讨论。您需要使用逗号分隔的列表,但不能有空格。

例子:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" // required to work 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:ignore="contentDescription,SpUsage" > // comma separated list. NO blanks allowed! 

有关有效选项的列表,你可以在命令行列表,或使用Eclipse的皮棉错误检查由throrin19提到的名单:

lint --list > lint_options.txt 

lint documentation

+0

这是我一直在寻找的信息。谢谢。 – RTF

+3

这应该是可以接受的答案。干杯! – portfoliobuilder

+0

这正是我所发现的。 :) – iroiroys

2

你可以把多个注解特定字符串忽略多个皮棉检查:

的strings.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources>  

    <!--suppress MissingTranslation --> 
    <!--suppress TypographyDashes --> 
    <string name="some_string">ignore my translation</string> 
    ... 

</resources> 

http://tools.android.com/tips/lint/suppressing-lint-warnings