- 浏览: 1501884 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (419)
- XMPP (19)
- Android (180)
- Java (59)
- Network (4)
- HTML5 (13)
- Eclipse (9)
- SCM (23)
- C/C++ (4)
- UML (4)
- Libjingle (15)
- Tools&Softwares (29)
- Linphone (5)
- Linux&UNIX (6)
- Windows (18)
- Google (10)
- MISC (3)
- SIP (6)
- SQLite (5)
- Security (4)
- Opensource (29)
- Online (2)
- 文章 (3)
- MemoryLeak (10)
- Decompile (5)
- Ruby (1)
- Image (1)
- Bat (4)
- TTS&ASR (28)
- Multimedia (1)
- iOS (20)
- Asciiflow - ASCII Flow Diagram Tool.htm (1)
- Networking (1)
- DLNA&UPnP (2)
- Chrome (2)
- CI (1)
- SmartHome (0)
- CloudComputing (1)
- NodeJS (3)
- MachineLearning (2)
最新评论
-
bzhao:
点赞123!
Windows的adb shell中使用vi不乱码方法及AdbPutty -
wahahachuang8:
我觉得这种东西自己开发太麻烦了,就别自己捣鼓了,找个第三方,方 ...
HTML5 WebSocket 技术介绍 -
obehavior:
view.setOnTouchListenerview是什么
[转]android 一直在最前面的浮动窗口效果 -
wutenghua:
[转]android 一直在最前面的浮动窗口效果 -
zee3.lin:
Sorry~~
When I build "call ...
Step by Step about How to Build libjingle 0.4
Android Lint is a new tool for ADT 16 (and Tools 16) which scans Android project sources for potential bugs. It is available both as a command line tool, as well as integrated with Eclipse. The architecture is deliberately IDE independent so it will hopefully be integrated with other IDEs, with other build tools and with continuous integration systems as well.
Here are some examples of the types of errors that it looks for:
- Missing translations (and unused translations)
- Layout performance problems (all the issues the old
layoutopt
tool used to find, and more) - Unused resources
- Inconsistent array sizes (when arrays are defined in multiple configurations)
- Accessibility and internationalization problems (hardcoded strings, missing contentDescription, etc)
- Icon problems (like missing densities, duplicate icons, wrong sizes, etc)
- Usability problems (like not specifying an input type on a text field)
- Manifest errors
and many more.
New November 24th: We just added some new lint rules.
See this document for a full list of the current checks performed by lint. Lint is still in development, so the list of rules will be increasing. In addition, we have an API in development which will make it possible (and hopefully easy) to add additional custom checks.
For information on how to suppress specific lint warnings, see the suppressing warnings document.
Command Line Usage
There is a command line tool in the SDK tools/ directory called
If you have the SDK lint
.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 /src/astrid/
Scanning GreenDroid-GoogleAPIs: ..
Scanning stream: ...
Scanning api: ...........................
Scanning GDCatalog: .......................
Scanning GreenDroid: ...........................................................
Scanning tests: ...
Scanning filters: ....
Scanning tests: .....
Scanning astrid: ....................................................................................................................................................
Scanning simple: .......
api/res/values-ca: Error: Locale ca is missing translations for: sync_SPr_bgwifi_key, sync_SPr_forget_key, sync_SPr_interval_values, sync_SPr_logged_in_prefix... (2 more) [MissingTranslation]
astrid/res/values-ca: Error: Locale ca is missing translations for: DLG_cancel, DLG_dismiss, DLG_ok, EPr_deactivated... (117 more) [MissingTranslation]
api/res/values-cs: Error: Locale cs is missing translations for: sync_SPr_bgwifi_key, sync_SPr_forget_key, sync_SPr_interval_values, sync_SPr_logged_in_prefix... (2 more) [MissingTranslation]
(many lines omitted)
43 errors, 466 warnings
Disabling Checks
The “id” for each type of error is shown in brackets after the error message, such as “MissingTranslation” above.
You can disable a specific check, or a list of checks, by adding the --disable argument, e.g.
Note that you can list categories as well, such as “Usability:Icons” above, which is the Icons subcategory of the Usability category.
You can disable a specific check, or a list of checks, by adding the --disable argument, e.g.
$ lint --disable MissingTranslation,UnusedIds,Usability:Icons /src/astrid/
Note that you can list categories as well, such as “Usability:Icons” above, which is the Icons subcategory of the Usability category.
Some checks are disabled by default. These can be enabled by adding the
Finally, you can specify which exact checks to run with the
To find out which id’s and categories are available, run
And to get the explanation for a specific issue use the
--enable
flag.Finally, you can specify which exact checks to run with the
--check
flag. This lets you look for a specific problem in the codebase, such as:$ lint --check MissingPrefix /src/astrid/
To find out which id’s and categories are available, run
$ 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
...
And to get the explanation for a specific issue use the
--show
command along with a list of id’s or categories (or no arguments at all to see everything):$ 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.
HTML Reports
The command line tool can also generate HTML reports. This has some advantages over the plain lint output:
By default, links to source files will just use local file:// path resources. You can remap the URLs to a different prefix with the --url option. For example:
- It includes the longer explanations associated with each issue, and hyperlinks to More Info for issues which provide a more info attribute.
- It includes the actual source code line with the error (and a window of 3 lines around it).
- It can contain links to the associated source files
- For icon errors, the icons themselves are shown in the report for comparison purposes
--html filename
as an argument:$ lint --html /tmp/report.html
By default, links to source files will just use local file:// path resources. You can remap the URLs to a different prefix with the --url option. For example:
$ lint --html /tmp/report.html --url /src/MyProj=http://buildserver/src/MyProj
Other Command Line Options
Lint is integrated with ADT 16. The integration offers a few features above the command line version of lint:
- 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
- Ability to configure issue severities
- Jump directly to the problem source from the lint view
Automatic Lint
Lint will be run automatically when you:
- 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.
- 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.
- 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).
Lint Window
To run Lint on a project, select the project in the package explorer and click on the Lint toolbar action (see image on the right).
Alternatively you can right click on the project and in the Android Tools sub menu, there is a “Run Lint” action. This will open a Lint Window which contains the various errors. Selecting an error will show the associated explanation in the text area on the right.
You can double click on errors in the lint view to jump to the associated source location, if any. The icon of each warning will indicate its severity, and for warnings which have fixes (see next section) there is a small light bulb overlay.
The window also has an action bar (in the upper right hand side corner), which lets you
- Run the lint checks again to refresh the results (which turns into a Stop button during the refresh if you want to abort it)
- Run the fix associated with this error, if any
- Ignore this fix
- Remove the warning marker
- Remove all warning markers
Quick Fixes
Many lint warnings have automatic fixes. For example, the various layoutopt fixes suggest replacements (e.g. replace wrap_content with 0dp).
- From the lint view, 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.
Suppressing Errors
From the editor quick fix menu, you can also choose to
These choices are stored in a file named
- Ignore the warning in this file only
- Ignore the warning in this project
- Ignore the warning, period.
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).Options
To edit the global lint options, which are the fallback options used for all projects, invoke the normal Eclipse options dialog and choose Android > Lint Options:
If you select an issue, you can edit its Severity in the dropdown on the bottom right. This lets you designate certain issues as Errors for example (which will abort Export APK if the option near the top of the dialog is enabled).
To turn off an issue check completely, choose “Ignore” as the severity.
Note that this does not edit the per-project lint settings. Open the Project settings dialog (right click on the project), where you’ll find a property page for Android Lint. Manual severity edits in the options dialog are also recorded in the
lint.xml
file along with suppressed errors, so others in your team will get the same severity designations you edit for the project. Installation
We plan to make an early access release of ADT 16 when things settle down a little.
For the impatient the source code is available in the git source code repository, in the
sdk/lint
folder. (See http://source.android.com/source/downloading.html for instructions, and get the code in the master repository).Known Bugs
- Quick Fix Menu Doesn’t Show: There is a current bug that many XML files in ADT open up with the default Eclipse XML editor instead of our custom Android one. The Quick Fixes only work for Android XML editors (which these files should have opened with). If this happens, right click on the file in the package explorer and use the “Open With” action to reopen the file in one of the Android XML editor types. This issue (21124) should be fixed in ADT 16.
- Unused Resources: The unused resource detector may incorrectly consider some resources to be unused. When lint is run from the command line, it just uses some simple string analysis to look for resource references. While it does try to ignore comments and string literals etc, it may still get tripped up. When lint is run inside of Eclipse it uses a parse tree so the results should be more accurate. The plan is to integrate a full parse into the lint core such that it doesn't matter where you run it.
- Overdraw Detector: Like the unused detector, this requires analyzing Java code, and this is currently not done with a proper Java parse tree (and unlike the unused resource detector, that's also true when run within Eclipse).
发表评论
-
[Android] 为Android安装BusyBox —— 完整的bash shell
2013-12-27 10:19 1482http://www.cnblogs.com/xiaowen ... -
Windows的adb shell中使用vi不乱码方法及AdbPutty
2013-12-27 10:17 7546http://www.veryhuo.com/down/ht ... -
AppMobi推出新XDK,可创建测试PhoneGap项目
2012-09-03 13:39 2627AppMobi今天发布了一个新的工具PhoneGap Mobi ... -
Sencha
2012-09-03 12:59 1182http://www.sencha.com/ Se ... -
jQuery Mobile学习
2012-09-01 12:33 1683使用Jquery Mobile设计Android通讯录 ... -
BackBone
2012-09-01 12:34 1256Backbone.js 是一种重量级javascript M ... -
jQTouch
2012-08-30 15:57 981A Zepto/jQuery plugin for mobil ... -
SwiFTP
2012-08-30 15:43 1298SwiFTP is a FTP server that run ... -
kWS
2012-08-30 15:41 1195kWS is a lightweight and fast W ... -
jQuery Mobile
2012-08-30 15:07 1021http://jquerymobile.com/ -
PhoneGap
2012-08-30 15:07 1040http://phonegap.com/ -
Android Button background image pressed/highlighted and disabled states without
2012-08-06 12:49 1673http://shikii.net/blog/android- ... -
[AndriodTips]Image, saved to sdcard, doesn't appear in Android's Gallery app
2012-08-04 16:15 1154http://stackoverflow.com/questi ... -
Voice detection for Android
2012-07-23 11:39 2341Here it is, my fist JAVA applic ... -
[AndroidTip]local reference table overflow (max=512)的错误解决
2012-07-22 22:56 6036JNI层coding经常会遇到ReferenceTable o ... -
[AndroidTip]EditText如何初始状态不获得焦点?
2012-07-22 15:35 1222最简单的办法是在EditText前面放置一个看不到的Linea ... -
[AndroidTip]android textview滚动条
2012-07-21 14:29 1293本来是想做一个显示文字信息的,当文字很多时View的高度不能超 ... -
Google公布Android 4.1完整功能
2012-07-16 09:48 3178http://www.android.com/about/je ... -
Android开发:使用AudioTrack播放PCM音频数据【附源码】
2012-07-13 15:20 20840http://www.linuxidc.com/Linux/2 ... -
Android上的行车记录仪
2012-07-11 22:31 2007MyCar Recorder DailyRoads
相关推荐
《Android-Lint简易工具Lin详解》 在Android应用开发中,代码质量的把控至关重要,而Android Lint就是谷歌提供的一款静态代码分析工具,用于检查代码中的潜在问题,如性能优化、错误处理、可用性等。然而,对于一些...
Android Lint checks. It uses Java byte code instrumentation to collect and report performance statistics per detector for a Lint analysis invoked from Gradle. It relies on YourKit Probes to do the ...
在Android开发过程中,保持代码质量是非常重要的,而`AndroidLint`是Google提供的一款静态代码分析工具,用于检测潜在的代码问题、性能优化建议以及遵循编码规范。本项目"基于注释的Androidlint检查生成"专注于利用...
Android Lint工具是一款强大的静态代码分析工具,专用于检测Android应用程序中的潜在问题。它能帮助开发者识别并修复代码中的各种问题,包括性能优化、错误预防、废弃资源清理等多个方面。以下是对Android Lint工具...
sonar Android Lint插件
在Android开发过程中,确保代码质量是非常重要的,而`Lint`工具正是为了这一目的而存在的。`Lint`是一款静态代码分析工具,它能检测出代码中潜在的问题,如性能优化、错误处理、API使用不当等。然而,标准的Android ...
Android Lint是Android开发中的一个静态代码分析工具,它能够检查代码中的潜在问题,包括错误、性能优化建议、可用性问题、国际化问题等。"android-lint-plugin: Jenkins的Android Lint解析器插件"是将这个功能集成...
在Android开发过程中,Android Lint是一个非常重要的静态代码分析工具,它能帮助开发者发现并修复潜在的代码问题、性能优化建议、编码规范等。本文将详细介绍如何以更美观、直观的方式来展示Android Lint检测出的...
Android Lint 是一个静态代码分析工具,用于检测 Android 应用程序中的潜在错误和不良实践。这个名为 "android-lint-summary" 的开源项目专注于提供一个更美观、更易读的方式来展示 Lint 检查的结果。它使得开发者...
Android Lint 这是一个通用Android Lint库,你可以用它来检查代码规范,bug,资源命名等 :victory_hand: 。 本库最大特点是通用,相较于其他Lint库(规则直接在代码写死),最大的不同是,规则全靠配置生成,更加...
而"Android-Android自定义Lint检查"则涉及到如何扩展Lint的功能,为你的项目或团队定制专属的检查规则。 首先,理解Lint的基本工作原理至关重要。Lint通过扫描项目中的源代码、资源文件和构建配置,寻找可能的问题...
Android lint 规则添加一些规则结帐后,将local.properties.dist复制到local.properties 。 该文件中提供的路径应该是正确的,以便 lint 找到自定义规则。 然后运行: gradle assemble uploadArchives在任何带有...
在Android开发过程中,lint工具是不可或缺的静态代码分析器,用于检测代码中的潜在问题和错误。自定义lint规则允许开发者根据项目需求扩展lint的功能,确保代码质量并遵循特定的编码规范。下面将详细介绍如何在...
anger-android_lint基于gradle的Android项目的Lint文件。 通过全局gems安装$ $ gem installanger-android_lint通过Bundler将以下行添加到您的Gemfile中,然后ruanger-android_lint基于gradle的Android项目的Lint文件...
Android Lint是Google提供的一款强大的静态代码分析工具,专门针对Android应用开发。它可以在编码阶段就发现潜在的问题,包括但不限于性能优化、可用性、安全性和兼容性等方面。通过对源代码进行深度扫描,Lint能...
Android Lint Plugin for Jenkins Parses output from the Android lint tool and displays the results for analysis. https://wiki.jenkins-ci.org/display/JENKINS/Android Lint Plugin
GitHub行动:使用reviewdog运行Android Lint 此操作使用带有运行。 输入项 github_token 必填项。 必须采用github_token: ${{ secrets.github_token }}形式github_token: ${{ secrets.github_token }} 。 lint_xml...
危险-android_lint 基于gradle的Android项目的Lint文件。 安装 通过全球宝石 $ gem install danger-android_lint 通过邦德勒 将以下行添加到您的Gemfile中,然后运行bundle install : gem 'danger-android_lint' ...