LoginSignup
16
16

More than 5 years have passed since last update.

Androidのlintチェックの基本

Posted at

チェック方法

下記コマンドを実行するだけ

$ ./gradlew check

実行結果は $buildDir/outputs/lint-results.html に出力される。

:app:lint
Wrote HTML report to file:/Users/mattak/project/sample/app/build/outputs/lint-results.html
Wrote XML report to /Users/mattak/project/sample/app/build/outputs/lint-results.xml
:app:preCompileDebugUnitTestJava

lintのオプション設定

何かエラーが出てcheck taskが失敗することは多々ある。
利用しているライブラリの都合でlintチェックが失敗しており、対応が行えない項目などがあるかもしれない。
そのようなと場合には、lintOptionsを設定して回避することができる。

例: okhttpの Invalid package reference in library

例えば okhttpのissue#896 で報告されているようなケースを除外する。

okio_lint_error.png

1) build.gradleにlintOptionsのlintConfigファイルを指定する。

build.gradle
android {
    lintOptions {
        lintConfig file('lint.xml')
    }
}

2) lint.xmlで指定のパッケージを除外する

lint.xml
<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="InvalidPackage">
        <ignore regexp="okio-1.0.1.jar" />
    </issue>
</lint>

これでbuildすれば lint checkが通るようになる。

lint optionsの詳細

より詳しくは下記を参照

16
16
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16