Android Lint reports OldTargetApi when targetSdkVersion is 29

Viewed 472

I'm getting the following Lint error on Github Actions (current CI solution for the project)

 > Task :application:lint FAILED
Ran lint on variant debug: 1 issues found
Ran lint on variant release: 1 issues found
Wrote HTML report to file:///~/application/build/reports/lint/lint-results.html

64 actionable tasks: 55 executed, 9 from cache
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':application:lint'.
> Lint found errors in the project; aborting build.

android {
    lintOptions {
        abortOnError false
    }
}
...
Errors found:
  
~/application/build.gradle.kts:17: Error: Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details. [OldTargetApi]
          targetSdkVersion(29)
                           ~~

My targetSdkVersion is set to 29 already.

enter image description here

If I run the exact same command locally ( ./gradlew build), no lint error is reported.

enter image description here

Some local environment data:

  • Gradle wrapper 6.5
  • Android Gradle Plugin 4.1.0-beta02
  • Kotlin 1.3.72
  • JDK 1.8.0_242

Any ideas on why this supposedly "contained" build is resulting in different outputs?

1 Answers

Not a proper solution, just a temporary workaround if you don't want to disable lint checks.

Create a lint.xml file in your app folder and list your build.gradle file to be ignored by lint:

<lint>
    <issue id="OldTargetApi">
        <ignore path="build.gradle"/>
    </issue>
</lint>
Related