当targetSdkVersion为29时,Android Lint报告OldTargetApi

时间:2020-06-26 11:47:17

标签: android android-gradle-plugin android-lint

我在Github Actions(该项目的当前CI解决方案)上遇到以下Lint错误

 > 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)
                           ~~

我的targetSdkVersion已设置为29

enter image description here

如果我在本地运行完全相同的命令(./gradlew build),则不会报告棉绒错误。

enter image description here

一些本地环境数据:

  • 渐变包装6.5
  • Android Gradle插件4.1.0-beta02
  • 科林1.3.72
  • JDK 1.8.0_242

关于为什么这个所谓的“包含”构建会导致不同的输出的任何想法?

1 个答案:

答案 0 :(得分:1)

如果您不想禁用 lint 检查,这不是一个合适的解决方案,只是一个临时解决方法。

在您的 lint.xml 文件夹中创建一个 app 文件并列出要被 lint 忽略的 build.gradle 文件:

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