[Android Memory] Android Lint简介(转载)
英文原文:http://tools.android.com/tips/lint 参照文章:http://blog.csdn.net/thl789/article/details/8037473
转载地址:http://blog.csdn.net/hudashi/article/details/8333349

New Lint Checks and Writing
Custom Lint Rules.
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)
ScanningTest:.........................................................................................................
........................................................................................................................
...................
ScanningTest(Phase2):......
res\layout\internet_image_demo.xml:9:Warning:The id "button1"isnot referring to any views inthis layout [UnknownIdI
nLayout]
android:layout_alignLeft="@+id/button1"
^
res\layout\internet_image_demo.xml:10:Warning:The id "textView1"isnot referring to any views inthis layout [Unknown
IdInLayout]
android:layout_below="@+id/textView1"
^
AndroidManifest.xml:52:Warning:Exported receiver does notrequire permission [ExportedReceiver]
<receiver android:name=".AlarmReceiver">
^
res\menu\activity_main.xml:Warning:The resource R.menu.activity_main appears to be unused [UnusedResources]
res\drawable-hdpi\ic_action_search.png:Warning:The resource R.drawable.ic_action_search appears to be unused [UnusedRe
sources]
res\values\strings.xml:7:Warning:The resource R.string.hello appears to be unused [UnusedResources]
<string name="hello">你好!</string>
^
res\drawable-mdpi:Warning:Missing the following drawables in drawable-mdpi: icon.png, icon2.png [IconDensities]
res\drawable-xhdpi:Warning:Missing the following drawables in drawable-xhdpi: icon.png, icon2.png [IconDensities]
res\layout\internet_image_demo.xml:5:Warning:[Accessibility]Missing contentDescription attribute on image [ContentDes
cription]
<ImageView
^
res\layout\activity_main.xml:17:Warning:[I18N]Hardcodedstring"go Hello", should use@string resource [HardcodedText
]
android:text="go Hello"
^
res\layout\activity_main.xml:23:Warning:[I18N]Hardcodedstring"打印所有任务栈信息", should use@string resource [Har
dcodedText]
android:text="打印所有任务栈信息"
^
res\layout\activity_main.xml:29:Warning:[I18N]Hardcodedstring"打印所有服务信息", should use@string resource [Hardc
odedText]
android:text="打印所有服务信息"
^
res\layout\activity_main.xml:35:Warning:[I18N]Hardcodedstring"打印进程信息", should use@string resource [Hardcoded
Text]
android:text="打印进程信息"
^
res\layout\hello.xml:23:Warning:[I18N]Hardcodedstring"please click me", should use@string resource [HardcodedText]
android:text="please click me"
^
0 errors,14 warnings
$ lint --disable MissingTranslation,UnusedIds,Usability:Icons/src/astrid/
$ lint --disable MissingTranslation,UnusedIds,Usability:Icons/src/astrid/
$ lint --listValid issue categories:CorrectnessSecurityPerformanceUsabilityUsability:IconsAccessibilityInternationalization
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 MissingPrefixMissingPrefix-------------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 检查规则列表》来查阅检查项的id等详细信息

$ 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)该检查规则
Columns lets you edit which columns are visible. There are several new
columns you can display, such as Category, Priority, etc, and you
can click on column headers to sort the display by the given column.
There's also a new "Location" column, shown by default, which
incorporates several different pieces of information: the file name, the
line number, the parent folder name (useful when looking
at translation or configuration issues), and the project name:

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
lint warnings have automatic fixes. For example, the various layoutopt
fixes suggest replacements (e.g. replace wrap_content with 0dp).
- 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.
you can also choose to
- 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 Memory] Android Lint简介(转载)的更多相关文章
- [Android Memory] android 警告:Exported activity does not require permission
在一个应用程序中添加了多个antivity后,在manifest.xml文件中会除了主Activity外,其它的Activity属性中都会有个警告: Exported activity does no ...
- [Android Memory] Android内存管理、监测剖析
转载自:http://blog.csdn.net/anlegor/article/details/23398785 Android内存管理机制: Android内存管理主要有:LowMemory Ki ...
- [Android Memory] Android Zipalign zip对齐优化app程序
转载地址:http://www.cnblogs.com/xirihanlin/archive/2010/04/12/1710164.html 参考文章:http://www.cnblogs.com/l ...
- [Android Memory] Android性能测试小工具Emmagee
转载:http://blog.csdn.net/anlegor/article/details/22895993 Emmagee是网易杭州QA团队开发的用于测试指定android应用性能的小工具.该工 ...
- [Android Memory] Android 的 StrictMode
android的2.3 之后引入的StrictMode 对网络的访问做了限制啊. public void onCreate() { if (DEVELOPER_MODE) { StrictMode.s ...
- [Android Memory] Android系统中查看某个应用当前流量的方法
转载自: http://blog.sina.com.cn/s/blog_628cc2b70101dbyy.html 一.查看原理:某个应用的网络流量数据保存在系统的/proc/uid_stat/$UI ...
- Android Lint简介(转)
转载自原文:http://blog.csdn.net/hudashi/article/details/8333349,感谢原作者. 英文原文:http://tools.android.com/tips ...
- Android Lint简介
Android Lint是SDK Tools 16 (ADT 16)之后才引入的工具,通过它对Android工程源代码进行扫描和检查,可发现潜在的问题,以便程序员及早修正这个问题.Android Li ...
- Android休眠唤醒机制简介(二)
本文转载自:http://blog.csdn.net/zhaoxiaoqiang10_/article/details/24408911 Android休眠唤醒机制简介(二)************* ...
随机推荐
- HDU2096 小明A+B
入门级都没到的水题!看到顺便就做了,AC记录喜+1 Description 小明今年3岁了, 现在他已经能够认识100以内的非负整数, 并且能够进行100以内的非负整数的加法计算. 对于大于等于100 ...
- 在cmd下编译一个简单的servlet时出现程序包javax.servlet不存在
由于servlet和JSP不是Java平台JavaSE(标准版)的一部分,而是Java EE(企业版)的一部分,因此,必须告知编译器servlet的位置. 解决“软件包 javax.servlet不存 ...
- SPOJ Play on Words
传送门 WORDS1 - Play on Words #graph-theory #euler-circuit Some of the secret doors contain a very inte ...
- 如何做一名好的web安全工程师?
在网络安全行业里面,web安全方向的人相对来说算是占大头,因为web安全初学阶段不像系统底层安全那么枯燥,而且成功hack目标网站的成就感相对也是比较强的. web安全工程师这个职位在甲方和乙方公司都 ...
- apache配置多个虚拟主机
设置apache 多个虚拟目录记录 #配置第2个虚拟目录<VirtualHost 127.0.0.2:80>ServerName www.xx.comDocumentRoot " ...
- Y2K Accounting Bug(贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10945 Accepted: 54 ...
- IOS开发的目录结构
http://www.itjhwd.com/iosmolukaifa/ 目录结构 个人总结: =============================================== ...
- MFC 最大化 的时候控件 按比例变大
在dlg类头文件中声明CPoint Old; 在BEGIN_MESSAGE_MAP()和END_MESSAGE_MAP()声明一个映射:ON_WM_SIZE() 这样以后就可以在M_SIZE事件的时候 ...
- zb的生日
http://acm.nyist.net/JudgeOnline/problem.php?pid=325 zb的生日 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 ...
- winform 添加“设置文件”
添加配置文件 ·右击服务项目---添加新项---设置文件:----确定 ·把Settings1.settings,拖到properties里,双击Settings1.settings: 名称:是自己定 ...