編輯:關於Android編程
gradle
中有lint
任務,可以直接執行lint靜態代碼檢查,但是前提是你的build.gradle
設置了lintOptions
選項:
android {
compileSdkVersion 23
buildToolsVersion 21.1.2
lintOptions {
abortOnError false
}
然後我們在項目的根目錄下執行gradle lint
:
localhost:Sunshine-Version-2 wuxian$ gradle lint
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72102Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42102Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileLint
:app:checkReleaseManifest
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:lint
Ran lint on variant release: 58 issues found
Ran lint on variant debug: 58 issues found
Wrote HTML report to file:/Users/wuxian/Documents/sourcecode/self/Sunshine-Version-2/app/build/outputs/lint-results.html
Wrote XML report to /Users/wuxian/Documents/sourcecode/self/Sunshine-Version-2/app/build/outputs/lint-results.xml
BUILD SUCCESSFUL
Total time: 17.941 secs
This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
在build/outputs/
目錄下會生成一個lint-result.html
文件,打開一看如下:
報告做的太次了<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxoMiBpZD0="總結">總結
這種方式適合自動化CI系統中采集結果。
選在分析代碼後,彈出對話框,你可以選擇分析整個項目/單個模塊/文件bulabula:
點擊OK後,等待一段時間後分析完畢,會自動彈出結果窗口
會根據檢查類型不同分不同菜單,點擊相應菜單進入不同的問題點:
點擊問題點後右邊會出現該問題的詳細信息,文件名,文件位置,出現問題的點在文件中的位置以及問題描述,還會告訴你忽略這個問題的解決方法,有可能還會顯示解決方法。
這個方法適合看法自查!
lint
工具位於sdk
目錄下的tools
下,如果在命令行執行lint找不到該命令,那麼需要將lint
的根目錄配置到環境變量中,配置成功後,執行lint
命令輸出如下:
58deMacBook-Pro-5:tools wuxian$ lint
Usage: lint [flags]
Flags:
--help This message.
--help Help on the given topic, such as suppress.
--list List the available issue id's and exit.
--version Output version information and exit.
--exitcode Set the exit code to 1 if errors are found.
--show List available issues along with full explanations.
--show Show full explanations for the given list of issue
id's.
Enabled Checks:
--disable Disable the list of categories or specific issue
id's. The list should be a comma-separated list of
issue id's or categories.
--enable Enable the specific list of issues. This checks all
the default issues plus the specifically enabled
issues. The list should be a comma-separated list of
issue id's or categories.
--check Only check the specific list of issues. This will
disable everything and re-enable the given list of
issues. The list should be a comma-separated list of
issue id's or categories.
-w, --nowarn Only check for errors (ignore warnings)
-Wall Check all warnings, including those off by default
-Werror Treat all warnings as errors
--config Use the given configuration file to determine whether
issues are enabled or disabled. If a project contains
a lint.xml file, then this config file will be used
as a fallback.
Output Options:
--quiet Don't show progress.
--fullpath Use full paths in the error output.
--showall Do not truncate long messages, lists of alternate
locations, etc.
--nolines Do not include the source file lines with errors in
the output. By default, the error output includes
snippets of source code on the line containing the
error, but this flag turns it off.
--html Create an HTML report instead. If the filename is a
directory (or a new filename without an extension),
lint will create a separate report for each scanned
project.
--url filepath=url Add links to HTML report, replacing local path
prefixes with url prefix. The mapping can be a
comma-separated list of path prefixes to
corresponding URL prefixes, such as
C: empProj1=http://buildserver/sources/temp/Proj1.
To turn off linking to files, use --url none
--simplehtml Create a simple HTML report
--xml Create an XML report instead.
Project Options:
--resources
問題描述:用React Native架構的無論是Android APP還是iOS APP,在啟動時都出現白屏現象,時間大概1~3s(根據手機或模擬器的性能不同而不同)。問
本節為大家提供有關物理游戲的知識,講解了一個簡單的圓形自由落體Demo的編寫。本文要介紹的重力系統實際上是類似的。 &nbs
首先需要先介紹下LayoutAnimationController: * 1.LayoutAnimationController用於為一個layo
多線程下載是加快下載速度的一種方式,通過開啟多個線程去執行一個任務..可以使任務的執行速度變快..多線程的任務下載時常都會使用得到..比如說我們手機內部應用寶的下載機制.