Search code examples
android-studioandroid-lint

How to make Android Studio build fail on lint errors


Is it possible to make Android Studio build fail on lint check errors ? I have problems with ImageViews when I convert icon from .png to vector drawable .xml Sometimes I forgot to change android:src="@drawable/ic_minus" to app:srcCompat="@drawable/ic_minus" and the app crashes on older OS devices.

?


Solution

  • If there's a lint check for that you can change the severity to FATAL and then when building the release version of your APK it should fail.

    android {
      lintOptions {
        fatal 'MY_LINT_CHECK_ID'
      }
    }
    

    Also you can execute the Gradle lint task which will fail. If you also want warnings to let your build fail you can use this.

    android {
      lintOptions {
        warningsAsErrors true
      }
    }