[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休眠唤醒机制简介(二)************* ...
随机推荐
- BZOJ3732 Network
Description 给你N个点的无向图 (1 <= N <= 15,000),记为:1…N. 图中有M条边 (1 <= M <= 30,000) ,第j条边的长度为: d_ ...
- BZOJ1034 [ZJOI2008]泡泡堂BNB
Description 第XXXX届NOI期间,为了加强各省选手之间的交流,组委会决定组织一场省际电子竞技大赛,每一个省的代表 队由n名选手组成,比赛的项目是老少咸宜的网络游戏泡泡堂.每一场比赛前,对 ...
- h5页面,改变数字默认颜色
最近遇到一个非常变态的bug,有一串数字,我设置color为白色,在pc端浏览器,无变化,但是到了手机端,会由白色跳成黑色,我无解啊... 刚刚找到方法,如下: <meta name=" ...
- 两个大的整数的运算(java)
import java.math.BigInteger; public class BigInt { BigInteger m1; BigInteger m2; BigInteger m3; BigI ...
- 代码重构-1 对参数中有 bool值的拆分
最近对一个同事的代码进行重构 第1步 对参数中有 bool值的拆分 原代码如下: private bool CheckIsInFreeTimes(GetDataForValidateLotteryRe ...
- web classpath 路径说明
classpath路径在每个J2ee项目中都会用到,即WEB-INF下面的classes目录,所有src目录下面的java.xml.properties等文件编译后都会在此,所以在开发时常将相应的xm ...
- iconv命令详解
功能] 对于给定文件把它的内容从一种编码转换成另一种编码. [描述] -f encoding :把字符从encoding编码开始转换. -t encoding :把字符转换到encoding编码. ...
- linux基本命令(4)-8.Ubuntu-jdk+tomcat+eclipse软件包安装
第一步 安装jdk su - root 切换成root用户 sudo -i 不需要密码直接切换成root 1.进入usr目录 cd /usr 2.在usr目录下建立java安装目录 mkdir jav ...
- 理解css中的line-height
在css中,line-height有下面五种可能的值:我们来看看w3c中列出如下可能值: normal:默认,设置合理的行间距. number:设置数字,此数字会与当前的字体尺寸相乘来设置行间距. l ...
- 【初级为题,大神绕道】The app icon set named "AppIcon" did not have any applicable content 错误#解决方案#
The app icon set named "AppIcon" did not have any applicable content 错误,怎样解决 按照您的错误提示您应该 ...