avoid lint when gradle execute check
Solution 1
gradle build -x lint
Source: Gradle User Guide : Excluding Tasks
Solution 2
You can skip it using adding -x lint
when you run the check
task:
./gradlew check -x lint
If you want to skip it permanently you can add this to your build.gradle
before apply plugin: 'com.android.application'
:
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
Solution 3
I just disabled the task during project setup:
android {
lintOptions {
tasks.lint.enabled = false
}
}
Note: it's not necessary to put the statement inside android.lintOptions
, but since it's configuring lint, it's nice to have them together.
Solution 4
Set checkReleaseBuilds
to false
will disable lint check on release build. Add following scripts to your build.gradle file:
lintOptions {
/**
* Set whether lint should check for fatal errors during release builds. Default is true.
* If issues with severity "fatal" are found, the release build is aborted.
*/
checkReleaseBuilds false
}
Solution 5
(Gradle 1.1.0, as packaged with Android Studio 1.1.0)
For anyone wondering how to do this with multiple subprojects, I ended up having to disable them using the root project build.gradle file like so:
task lintCheck() {
getAllTasks(true).each {
def lintTasks = it.value.findAll { it.name.contains("lint") }
lintTasks.each {
it.enabled = false
}
}
}
Jose M Lechon
Android Mobile Developer, however I'm opened to whatever language.
Updated on June 25, 2020Comments
-
Jose M Lechon almost 4 years
could someone tell me a way to avoid executing "lint" each time I run in gradle check?
I've defined in build.gradle
lintOptions { quiet true }
However, it keeps doing this task. The problem is that it takes ages each time I have to do a check.
-
Jose M Lechon over 10 yearsYes, finally I've started using this commands
./gradlew check -x lint
-
xbakesx about 10 yearsFor any future visitors, you may need to change "lint" to "lintVitalRelease" because #thegoogle renamed it.
-
Kai over 9 years@xbakesx I just disable all task with name starting with "lint", seem to work well enough
-
Display Name almost 9 yearsto which build.gradle? and where? the answer is not clear
-
sandrstar over 8 yearsHow / where do you call lintCheck() after it?
-
Zenel over 8 yearsIn my case I was able to add it as a dependency on build.
-
rastadrian about 8 years@SargeBorsch if you want to add the task.whenTaskAdded closure, you add it to your application module's build.gradle, and you can safely add that to the bottom of the file.
-
David Burström about 7 yearsPlease note that the whenTaskAdded closure solution is used, it will still invoke task dependencies, e.g. compiling all sources.
-
Akshat about 6 yearsperfect! worked for me. Had all other options but non worked except this