Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress Android Lint warning in Gradle script

I have the following annoying warning in my Android Lint report:

Gradle Dependency: Obsolete Gradle Dependency
A newer version of com.android.support:appcompat-v7 than 20.+ is available: 21.0.0-rc1

The problem is I cannot use 21.0.0-rc1 because it does not work with my project. How can I suppress the warning?

like image 498
friederbluemle Avatar asked Jul 04 '14 11:07

friederbluemle


People also ask

How do I turn off lint warning?

To suppress a lint warning with an annotation, add a @SuppressLint("id") annotation on the class, method or variable declaration closest to the warning instance you want to disable.

How do I get rid of warnings on Android?

Current projectPosition your cursor on the if statement and press Alt + Enter . Then choose Simplify > Disable inspection.

What is suppress lint?

android.annotation.SuppressLint. Indicates that Lint should ignore the specified warnings for the annotated element.

What is lint in gradle?

The Gradle Lint plugin is a pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts and related files.


1 Answers

You can disable lint warnings in Gradle. In this case:

android {

    lintOptions {
        disable 'GradleDependency'
    }

    ...

To disable the warning for a specific dependency, you can instead use the noinspection hint just above the line that causes the warning. Like this:

//noinspection GradleDependency
compile 'com.android.support:appcompat-v7:20.+'

In Android Studio, you can turn off the "Obsolete Gradle Dependency" warning in Settings -> Project Settings -> Inspections.

enter image description here

like image 105
matiash Avatar answered Oct 03 '22 01:10

matiash