Cause: compileSdkVersion is not specified. Please add it to build.gradle

这篇具有很好参考价值的文章主要介绍了Cause: compileSdkVersion is not specified. Please add it to build.gradle。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

新建了个项目,过一段时间之后再去编译,提示错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'MyApp'.
> compileSdkVersion is not specified. Please add it to build.gradle

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

很诧异,啥都没改,为什么突然就报错了呢?

于是一一排查,终于找到问题了,我项目APP中,依赖如下:

dependencies {

    ...
    implementation "androidx.core:core-ktx:+"
    ...
}

重点就是这个+,代表一直使用最新的版本,而最新版本有可能对compileSdk,tools版本产生各种要求,从而导致最终的编译不过。

而这个依赖库时创建项目时自动创建的,如果没有使用到删掉即可,如果使用,建议使用固定版本。

另外,项目的build.gradle文件中要声明好版本如下:

plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
}

类似的错误还有如下等等,都是由于这个问题导致的文章来源地址https://www.toymoban.com/news/detail-576721.html

1.  Dependency 'androidx.core:core:1.9.0-beta01' requires libraries and applications that
      depend on it to compile against version 33 or later of the
      Android APIs.

      :app is currently compiled against android-32.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.2.1 is 32.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 33, then update this project to use
      compileSdkVerion of at least 33.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).
2.  Dependency 'androidx.core:core-ktx:1.9.0-beta01' requires libraries and applications that
      depend on it to compile against version 33 or later of the
      Android APIs.

      :app is currently compiled against android-32.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.2.1 is 32.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 33, then update this project to use
      compileSdkVerion of at least 33.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).

到了这里,关于Cause: compileSdkVersion is not specified. Please add it to build.gradle的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包