I would like to be able to run the lint task when I\'m building projects with the android studio to ensure the lint rules are being followed.
I have tried using task
If you want to force Android Studio project to run the lint check before the default run configuration without affecting how your gradle tasks are configured, AND you want to do this in the gradle build system, then you can add the following block outside of the android
block in the app module's build.gradle as follows:
android {
....
lintOptions {
abortOnError true
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'compileDevDebugSources') {
task.dependsOn lint
task.mustRunAfter lint
}
}
Replace compileDevDebugSources
with the desired build variant that you have already defined, eg. compileReleaseSources
, compileDebugSources
, compileStagingDebugSources
, etc.
This was tested working on Android Studio 3.0