# Lint 支持
> Lint 支持,譯者注:Lint 是一個可以檢查 Android 項目中存在的問題的工具
從 0.7.0 版本開始,你可以為項目中一個特定的 variant(變種)版本運行 lint,也可以為所有 variant 版本都運行 lint。它將會生成一個報告描述哪一個 variant 版本中存在著問題。
你可以通過以下 lint 選項配置 lint。通常情況下你只需要配置其中一部分,以下列出了所有可使用的選項:
~~~
android {
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
// if true, emit full/absolute paths to files with errors (true by default)
//absolutePaths true
// if true, check all issues, including those that are off by default
checkAllWarnings true
// if true, treat all warnings as errors
warningsAsErrors true
// turn off checking the given issue id's
disable 'TypographyFractions','TypographyQuotes'
// turn on the given issue id's
enable 'RtlHardcoded','RtlCompat', 'RtlEnabled'
// check *only* the given issue id's
check 'NewApi', 'InlinedApi'
// if true, don't include source code lines in the error output
noLines true
// if true, show all locations for an error, do not truncate lists, etc.
showAll true
// Fallback lint configuration (default severities, etc.)
lintConfig file("default-lint.xml")
// if true, generate a text report of issues (false by default)
textReport true
// location to write the output; can be a file or 'stdout'
textOutput 'stdout'
// if true, generate an XML report for use by for example Jenkins
xmlReport false
// file to write report to (if not specified, defaults to lint-results.xml)
xmlOutput file("lint-report.xml")
// if true, generate an HTML report (with issue explanations, sourcecode, etc)
htmlReport true
// optional path to report (default will be lint-results.html in the builddir)
htmlOutput file("lint-report.html")
// set to true to have all release builds run lint on issues with severity=fatal
// and abort the build (controlled by abortOnError above) if fatal issues are found
checkReleaseBuilds true
// Set the severity of the given issues to fatal (which means they will be
// checked during release builds (even if the lint target is not included)
fatal 'NewApi', 'InlineApi'
// Set the severity of the given issues to error
error 'Wakelock', 'TextViewEdits'
// Set the severity of the given issues to warning
warning 'ResourceAsColor'
// Set the severity of the given issues to ignore (same as disabling the check)
ignore 'TypographyQuotes'
}
}
~~~
- 譯者序
- 簡介
- 新構建系統的目標
- 為什么使用 Gradle?
- 配置要求
- 基礎項目
- 構建文件示例
- 項目結構
- 配置項目結構
- 構建任務
- 通用任務
- Java 項目的 Task
- Android Tasks
- 基本的構建定制
- Manifest 屬性
- 構建類型
- 簽名配置
- 運行 ProGuard
- 清理資源
- 依賴、Library 和多項目
- 包依賴
- 本地包依賴
- 遠程包依賴
- 多項目設置
- Library 項目
- 創建 Library 項目
- 普通項目和 Library 項目的區別
- 引用 Library 項目
- Library 項目發布
- 測試
- 單元測試
- 基本知識和配置
- 運行測試
- 測試 Android Library 項目
- 測試報告
- 獨立項目
- 多項目報告
- Lint 支持
- 構建 Variants(變種)版本
- 產品定制
- 構建類型+產品定制=構建變種版本
- 產品定制的配置
- 源組件和依賴
- 構建和任務
- 測試
- 多定制的變種版本
- 高級構建的自定義
- 構建選項
- Java 編譯選項
- aapt 選項
- dex 選項
- 操作 task
- 構建類型和產物定制的屬性引用
- 使用sourceCompatibility 1.7
- 附錄
- ApplicationId 與 packageName