Android Lint简介(转)
转载自原文:http://blog.csdn.net/hudashi/article/details/8333349,感谢原作者。
英文原文:http://tools.android.com/tips/lint

lint
.If you have the SDK tools/
directory on your path, you can invoke it as “lint
”. Just point to a specific Android project directory. You can also point to a random directory, which (if it is not an Android project) will be searched recursively and all projects under that directory will be checked. (And you can also specify multiple projects separated by spaces)
$ lint --disable MissingTranslation,UnusedIds,Usability:Icons /src/astrid/
$ lint --disable MissingTranslation,UnusedIds,Usability:Icons /src/astrid/
$
lint
--list
Valid issue categories:
Correctness
Security
Performance
Usability
Usability:Icons
Accessibility
Internationalization
Valid issue id's:
"ContentDescription": Ensures that image widgets provide a contentDescription
"DuplicateIds": Checks for duplicate ids within a single layout
"StateListReachable": Looks for unreachable states in a <selector>
"InefficientWeight": Looks for inefficient weight declarations in LinearLayouts
"ScrollViewSize": Checks that ScrollViews use wrap_content in scrolling dimension
"MergeRootFrame": Checks whether a root <FrameLayout> can be replaced with a <merge> tag
...
$ lint --show MissingPrefix
MissingPrefix
-------------
Summary: Detect XML attributes not using the Android namespace
Priority: 8 / 10
Severity: Warning
Category: Correctness
Most Android views have attributes in the Android namespace. When
referencing these attributes you *must* include the namespace prefix,
or your attribute will be interpreted by aapt as just a custom
attribute.

$ lint --html /tmp/report.html --url /src/MyProj=http://buildserver/src/MyProj
- Automatic fixes for many warnings自动修正大量警告
- Lint gets run automatically on various editing operations当编辑操作完成后,立即自动运行
- Ability to suppress types of errors as well as specific instances of an error可以suppress(忽略)一种类型的erro,也可以suppress(忽略)特定的一个erro
- Ability to configure issue severities能够配置issue(问题)的severities(严重性)
- Jump directly to the problem source from the lint view通过lint视图能直接跳转到其问题对应的源码处
- Export an APK. In this case it runs lint in a special mode which only looks for fatal errors (which is faster) and aborts the export if any fatal errors are found. You can turn off this in the Lint Options.在导出APK文件的时候,lint会做快速的扫描,以寻找fatal的错误。如果发现有fatal的错误,导出APK的操作将被迫终止
- Edit and Save and XML file, such as a layout file or a manifest file. In this case, all the file-scope checks that apply to the given file are run and editor markers are added for any issues found.编辑和保存XML文件,lint也会自动扫描这些文件。另外从ADT20开始,对于java源码文件在编辑和保存后,lint也会对他们进行扫描。
- Use the layout editor. After every UI operation, file-scope checks (such as the various layoutopt rules) are run on the layout file and the results are shown in a special lint window (which can be opened from the error marker which shows in the top right corner of the layout editor when errors are found).对于使用layout editor来操作布局文件时,在每个UI操作后,lint也会自动扫描该布局文件。






Refresh, which re-runs the current analysis on the same projects
Fix, which automatically fixes the issue (this applies to issues where a quickfix is available)
Suppress this issue with an attribute or annotation
Ignore in this file (saves suppress information in lint.xml)
Ignore in this project (ditto)
Always ignore
Delete this lint marker
Delete all lint markers
Expand All,
Collapse All
Configure Columns用于设置在lint Window中对于检查出的issue的哪些项显示哪些项不显示,如图3-7所示
Edit Options Edit Options 点击该按钮会弹出Lint Preference dialog,如图1或图3-8在里面你可以定制默认/全局的Android Lint的基本检查规则,在其中可以设置所有项目默认的lint检查规则的检查级别,把检查级别(Severity)设为”ignore“,其实就是忽略(suppress)该检查规则

The Edit Options actions brings up the Lint Preference dialog, which has also been improved. You can now search through the options by filter:

3.3、Quick Fixes
- From the lint view(如图3-6所示), click the lightbulb
to invoke a fix. - From the layout editor warning summary, click the Fix button to fix.
- And from the XML source editor, invoke the Quick Fix (Ctrl-1 or Command-1) and pick the quick fix associated with the warning.
- Ignore the warning in this file only
- Ignore the warning in this project
- Ignore the warning, period.
- Ignore warnings using annotations or attributes, as explained here.

These choices are stored in a file named lint.xml
in the project, which is also read by the command line tool. Thus, you can ignore warnings from the UI, and check in thelint.xml
file with your source projects, and others running lint will not see warnings you have ignored (presumably because they have been manually verified).
lint.xml
文件中Android Lint简介(转)的更多相关文章
- [Android Memory] Android Lint简介(转载)
英文原文:http://tools.android.com/tips/lint 参照文章:http://blog.csdn.net/thl789/article/details/8037473 转载 ...
- Android Lint简介
Android Lint是SDK Tools 16 (ADT 16)之后才引入的工具,通过它对Android工程源代码进行扫描和检查,可发现潜在的问题,以便程序员及早修正这个问题.Android Li ...
- 【工利其器】Android Lint篇——为Android量身定做的静态代码审查工具
前言 我们在进行代码优化的时候,往往是通过开发者的经验来判断哪些代码可能存在潜在问题,哪些资源的使用不合规范等.实际上Android SDK提供了一款功能非常强大的工具,来帮助开发者自动检测代码的质量 ...
- 【Android应用开发】Android Studio 简介 (Android Studio Overview)
一. Intelij IDEA 环境简介 Android Studio 来源 : Android Studio 是 Intelij IDEA 的免费版本 + Android SDK 集成的; -- I ...
- Android Lint Checks
Android Lint Checks Here are the current list of checks that lint performs as of Android Studio 2.3 ...
- Android Studio 简介及导入 jar 包和第三方开源库方[转]
原文:http://blog.sina.com.cn/s/blog_693301190102v6au.html Android Studio 简介 几天前的晚上突然又想使用 Android Studi ...
- Android代码优化——使用Android lint工具
作为移动应用开发者,我们总希望发布的apk文件越小越好,不希望资源文件没有用到的图片资源也被打包进apk,不希望应用中使用了高于minSdk的api,也不希望AndroidManifest文件存在异常 ...
- Android代码优化工具——Android lint
作为移动应用开发者,我们总希望发布的apk文件越小越好,不希望资源文件没有用到的图片资源也被打包进apk,不希望应用中使用了高于minSdk的api,也不希望AndroidManifest文件存在异常 ...
- "浅谈Android"第一篇:Android系统简介
近来,看了一本书,名字叫做<第一行代码>,是CSDN一名博主写的,一本Android入门级的书,比较适合新手.看了书之后,有感而发,想来进行Android开发已经有一年多了,但欠缺系统化的 ...
随机推荐
- Unity3D Built-in Shader详解一
Unity3D内置了很多Shader,文档很详细,自己翻一下.便于加深印象. 首先先解释下Unity3D的Shader.Unity里面的Shaders是使用一种叫ShaderLab的语言编写的,它同微 ...
- android 蓝牙设备监听广播
蓝牙权限 <uses-permission android:name="android.permission.BLUETOOTH" /> 1.监听手机本身蓝牙状态的广播 ...
- Counting Squares[HDU1264]
Counting Squares Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- myeclipse下安装svn
在网上查了一下,安装的方法有几种,这里给大家推荐一种快速安装的方法. //第一步 : 下载 site-1.6.5.zip //===================================== ...
- LIS+LCS+LCIS
PS:本篇博文均采用宏#define FOR(i, a, n) for(i = a; i <= n; ++i) LIS:最长上升子序列 废话不多说:http://baike.baidu.com/ ...
- C# 使用 GetOleDbSchemaTable 检索架构信息(表、列、主键等)
本文演示如何用 ADO.NET 中 OleDbConnection 对象的 GetOleDbSchemaTable 方法检索数据库架构信息.数据源中的架构信息包括数据库或可通过数据库中的数据源.表和视 ...
- iOS开发之UITextField的使用详解
UITextField的使用详解 UITextField控件是开发中,使用频率比较高的控件了,那么有必要总结一下. 一.UITextField手动编写控件 UITextField *txtAccou ...
- rsync服务器的配置和使用
yum install -y rsyncuseradd rsync -s /sbin/nologinmkdir /backupmkdir /backup1 chown rsync:rsync /bac ...
- 导航栏下a标签失效的原因
前天我一直没找到失效的结果,就在刚才,我用不同的浏览器打开我编写的网页,有一个浏览器的图片循环播放效果错位了,我觉得就是它上边的div把他挤下来了.正如前天网上看到的高手的们的说法.我用firebug ...
- 分布式架构高可用架构篇_01_zookeeper集群的安装、配置、高可用测试
参考: 龙果学院http://www.roncoo.com/share.html?hamc=hLPG8QsaaWVOl2Z76wpJHp3JBbZZF%2Bywm5vEfPp9LbLkAjAnB%2B ...