本人博客原文
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
C:\Documents and Settings\Administrator>lint D:\workspace\Test Scanning Test: ......................................................................................................... ........................................................................................................................ ................... Scanning Test (Phase 2): ...... res\layout\internet_image_demo.xml:9: Warning: The id "button1" is not referring to any views in this layout [UnknownIdI nLayout] android:layout_alignLeft="@+id/button1" ^ res\layout\internet_image_demo.xml:10: Warning: The id "textView1" is not referring to any views in this layout [Unknown IdInLayout] android:layout_below="@+id/textView1" ^ AndroidManifest.xml:52: Warning: Exported receiver does not require 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] Hardcoded string "go Hello", should use @string resource [HardcodedText ] android:text="go Hello" ^ res\layout\activity_main.xml:23: Warning: [I18N] Hardcoded string "打印所有任务栈信息", should use @string resource [Har dcodedText] android:text="打印所有任务栈信息" ^ res\layout\activity_main.xml:29: Warning: [I18N] Hardcoded string "打印所有服务信息", should use @string resource [Hardc odedText] android:text="打印所有服务信息" ^ res\layout\activity_main.xml:35: Warning: [I18N] Hardcoded string "打印进程信息", should use @string resource [Hardcoded Text] android:text="打印进程信息" ^ res\layout\hello.xml:23: Warning: [I18N] Hardcoded string "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/
C:\Documents and Settings\Administrator>lint --disable Internationalization D:\workspace\TestScanning Test: ....................................................................................................................................................................................................................................................Scanning Test (Phase 2): ......res\layout\internet_image_demo.xml:9: Warning: The id "button1" is not referring to any views in this layout [UnknownIdInLayout]android:layout_alignLeft="@+id/button1"^res\layout\internet_image_demo.xml:10: Warning: The id "textView1" is not referring to any views in this layout [UnknownIdInLayout]android:layout_below="@+id/textView1"^AndroidManifest.xml:52: Warning: Exported receiver does not require 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 [UnusedResources]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 [ContentDescription]<ImageView^0 errors, 9 warnings
$ 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
"InefficientWeight": Looks for inefficient weight declarations in LinearLayouts
"ScrollViewSize": Checks that ScrollViews use wrap_content in scrolling dimension
"MergeRootFrame": Checks whether a root can be replaced with a 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.
C:\Documents and Settings\Administrator>lint --html D:\workspace\Test\report.html D:\workspace\TestScanning Test: ....................................................................................................................................................................................................................................................Scanning Test (Phase 2): ......Wrote HTML report to D:\workspace\Test\report.html
$ lint --html /tmp/report.html --url /src/MyProj=http://buildserver/src/MyProj
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 the
lint.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
文件中