I have an Android project defining
buildscript {
repositories {
jcenter()
}
dependencies {
// Android plugin for gradle
// http://google.github.io/android-gradle-dsl
classpath 'com.android.tools.build:gradle:1.5.0'
// ...
In my app I want to set
android {
// ...
lintOptions {
// http://google.github.io/android-gradle-dsl/1.5/com.android.build.gradle.internal.dsl.LintOptions.html#com.android.build.gradle.internal.dsl.LintOptions:severityOverrides
severityOverrides {
["MissingTranslation": "warning"]
}
// ...
but I get the error
Error:(34, 0) Gradle DSL method not found: 'severityOverrides()' Possible causes: The project 'android' may be using a version of Gradle that does not contain the method.
What is the correct way to set severityOverrides?
Versions that did compile but do not have the desired effect on the :app:lintVitalRelease
build step:
import com.android.builder.model.LintOptions
// ...
severityOverrides ["MissingTranslation": LintOptions.SEVERITY_WARNING]
and
import com.android.builder.model.LintOptions
// ...
severityOverrides.MissingTranslation = LintOptions.SEVERITY_WARNING
I would like to share what I'm doing.
Instead of set severityOverrides, you can call one method to each type of flag that you want to set.
lintOptions {
ignore "RtlEnabled", "RtlHardcoded", "RtlSymmetry" ....
warning "RtlEnabled", "RtlHardcoded", "RtlSymmetry" ....
error "RtlEnabled", "RtlHardcoded", "RtlSymmetry" ....
fatal "RtlEnabled", "RtlHardcoded", "RtlSymmetry" ....
informational "RtlEnabled", "RtlHardcoded", "RtlSymmetry" ....
}
In your case, you can do:
lintOptions {
warning "MissingTranslation"
}
I'm not sure if you can manually set severityOverrides since it is a read only property.
So, I think you really must call one of the methods above (error, fatal etc..) to override the property that you want
(Not an answer-answer, but this is what I used as an equivalent replacement when I couldn't get lintOptions.severityOverrides
to work)
Drop a lint.xml file with the same configuration at the root of the module.
<?xml version="1.0" encoding="UTF-8" ?>
<lint>
<issue id="MissingTranslation" severity="warning" />
</lint>
You also get a richer API to tune lint warnings through lint.xml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With