[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休眠唤醒机制简介(二)************* ...
随机推荐
- asp.net 回发或回调参数无效的各种情况分析及解决办法
昨天,在实现级联菜单的时候,突然出现一下错误: 回发或回调参数无效.在配置中使用 <pages enableEventValidation="true"/> 或在页面中 ...
- React Native 开发之 (02) 用Sublime 3作为React Native的开发IDE
Sublime Text是一个代码编辑器.也是HTML和散文先进的文本编辑器.漂亮的用户界面和非凡的功能,例如:迷你地图,多选择Python插件,代码段等等.完全可自定义键绑定,菜单和工具栏等等.漂亮 ...
- 静态内部类和Lazy<T>优雅实现单例
public class Singleton { private Singleton() { } public static Singleton GetInstance() { return Conc ...
- MyEclipse------带进度条的输入流
other.jsp <%@ page language="java" import="java.util.*" pageEncoding="UT ...
- web classpath 路径说明
classpath路径在每个J2ee项目中都会用到,即WEB-INF下面的classes目录,所有src目录下面的java.xml.properties等文件编译后都会在此,所以在开发时常将相应的xm ...
- WGS84、Web墨卡托、火星坐标、百度坐标互转
转自:1.http://blog.csdn.net/wildboy2001/article/details/12031351 2.http://kongxz.com/2013/10/wgs-cgj/ ...
- DOM 元素 属性和方法
console.dir() namespaceURI: "http://www.w3.org/1999/xhtml" nextElementSibling: null nextSi ...
- mybatis 使用动态SQL
RoleMapper.java public interface RoleMapper { public void add(Role role); public void update(Role ro ...
- Math.Round函数详解
有不少人误将Math.Round函数当作四舍五入函数在处理, 结果往往不正确, 实际上Math.Round采用的是国际通行的是 Banker 舍入法. Banker's rounding(银行家舍入) ...
- C# Window Service详解
Windows Service这一块并不复杂,但是注意事项太多了,网上资料也很凌乱,偶尔自己写也会丢三落四的.所以本文也就产生了,本文不会写复杂的东西,完全以基础应用的需求来写,所以不会对Window ...