Search code examples
androidgradlelintsuppress-warnings

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?


Solution

  • 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