Android Studio error "requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs."

huangapple go评论186阅读模式
英文:

Android Studio error "requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs."

问题

以下是翻译好的部分:

  1. 当检查AAR元数据时发现了2个问题:

    1. 依赖 'androidx.core:core:1.12.0-alpha05' 要求依赖它的库和应用程序进行编译时使用Android API的版本34或更高版本。

      :app 当前编译时使用的是android-33。

      此外,Android Gradle插件8.0.2的最大推荐编译SDK版本是33。

      建议操作:更新此项目的Android Gradle插件版本,以支持版本34,然后将此项目更新为至少使用compileSdk版本34。

      请注意,更新库或应用程序的compileSdk(允许使用较新的API)可以与更新targetSdk(将应用程序选择加入新的运行时行为)和minSdk(确定可安装应用程序的设备)分开进行。

    2. 依赖 'androidx.core:core-ktx:1.12.0-alpha05' 要求依赖它的库和应用程序进行编译时使用Android API的版本34或更高版本。

      :app 当前编译时使用的是android-33。

      此外,Android Gradle插件8.0.2的最大推荐编译SDK版本是33。

      建议操作:更新此项目的Android Gradle插件版本,以支持版本34,然后将此项目更新为至少使用compileSdk版本34。

      请注意,更新库或应用程序的compileSdk(允许使用较新的API)可以与更新targetSdk(将应用程序选择加入新的运行时行为)和minSdk(确定可安装应用程序的设备)分开进行。

我已将build.gradle文件(应用程序级别)中的compileSdk和targetSdk值从33增加到34,但在执行时出现了以下错误:

我们建议使用更新的Android Gradle插件来使用compileSdk = 34

此Android Gradle插件(8.0.2)经过测试最高支持compileSdk = 33。

强烈建议您更新项目以使用已经测试过compileSdk = 34的新版本Android Gradle插件。

如果您已经在使用最新版本的Android Gradle插件,您可能需要等待支持compileSdk = 34的新版本可用。

要消除此警告,请添加/更新android.suppressUnsupportedCompileSdk=34 到此项目的gradle.properties。

英文:

2 issues were found when checking AAR metadata:

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

    :app is currently compiled against android-33.

    Also, the maximum recommended compile SDK version for Android Gradle
    plugin 8.0.2 is 33.

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

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

  2. Dependency 'androidx.core:core-ktx:1.12.0-alpha05' requires libraries and applications that
    depend on it to compile against version 34 or later of the
    Android APIs.

    :app is currently compiled against android-33.

    Also, the maximum recommended compile SDK version for Android Gradle
    plugin 8.0.2 is 33.

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

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

I have increased compileSdk, targetSdk values from 33 to 34 in build.gradle file (app level), but then when executing I had this error:

We recommend using a newer Android Gradle plugin to use compileSdk = 34

This Android Gradle plugin (8.0.2) was tested up to compileSdk = 33.

You are strongly encouraged to update your project to use a newer
Android Gradle plugin that has been tested with compileSdk = 34.

If you are already using the latest version of the Android Gradle plugin,
you may need to wait until a newer version with support for compileSdk = 34 is available.

To suppress this warning, add/update
android.suppressUnsupportedCompileSdk=34
to this project's gradle.properties.

答案1

得分: 1

你需要更新:
android {
compileSdkVersion 34
...
defaultConfig {
applicationId "xxxxx"
targetSdkVersion 34 //flutter.targetSdkVersion
....
}
}
希望能够解决问题,帮助你。

英文:

You needed update:
android {
compileSdkVersion 34
...
defaultConfig {
applicationId "xxxxx"
targetSdkVersion 34 //flutter.targetSdkVersion
....
}
}
well pass issus hope help you.

答案2

得分: 1

我只使用'androidx.core:core:1.10.1'与Android Gradle插件8.0.2、gradle-8.0以及compileSdk/targetSdk 33。

如果不必要,我从不使用alpha版本。

英文:

I just use 'androidx.core:core:1.10.1' with Android Gradle plugin 8.0.2, gradle-8.0 and compileSdk/targetSdk 33.

I NEVER use alpha versions if I don't have to.

答案3

得分: 1

我在React Native中遇到了同样的问题。我已经通过使用最新的稳定版本来解决了它。

我在应用的build.gradle中添加了以下内容:

configurations.all {
  resolutionStrategy {
      force "androidx.core:core-ktx:1.10.1"
   }
}
英文:

I had same problem in react native. I have fixed it with using latest stable version.

I added this in app build.gradle

configurations.all {
  resolutionStrategy {
      force "androidx.core:core-ktx:1.10.1"
   }
}

答案4

得分: 0

你有多个解决此问题的选项。

  1. 降级 androidx.core:core:1.12.0-alpha05 依赖项。
  2. 将编译 SDK 版本和编译版本升级到 34,还要更新 Gradle 插件版本。(更新 Java SDK 到 11 或更高,因为最新的 Gradle 版本不支持旧的 Java 版本。)
英文:

You have multiple options for resole this issue.

  1. Downgrade androidx.core:core:1.12.0-alpha05' dependency
  2. Upgrade your compile SDK version and compile version to 34 also update gradle plugin version. (update java sdk 11 0r later. because latest gradle versions not support older java versions )

答案5

得分: 0

所以我只是在学习Android Studio。昨天我创建了一个编译正常的项目,但今天我开始遇到类似的错误(关于使用API 34),在任何新项目中都会出现这些错误,我感到非常疯狂。显然,我不知道为什么,但我在我的build.gradle.kts(模块:app)中更改了这些依赖项的版本:

  • implementation("androidx.navigation:navigation-fragment-ktx:2.7.0")
  • implementation("androidx.navigation:navigation-ui-ktx:2.7.0")
  • implementation("com.google.android.material:material:1.9.0")

改为:

  • implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
  • implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
  • implementation("com.google.android.material:material:1.8.0")

然后一切正常运作。

与这个特定错误无关,但这可能对其他人有用。

英文:

So i'm just learning Android Studio. Yersterday i created a project that compiled just fine, and today i started having similar errors (about using API 34 instead) with any new project and i was going totally crazy. Apparently, i don't know why, but changing the version for these dependencies in my build.gradle.kts (Module :app):

  • implementation("androidx.navigation:navigation-fragment-ktx:2.7.0")
  • implementation("androidx.navigation:navigation-ui-ktx:2.7.0")
  • implementation("com.google.android.material:material:1.9.0")

To:

  • implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
  • implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
  • implementation("com.google.android.material:material:1.8.0")

And then everything worked.

Not exactly related to this error in particular, but this may be useful for someone else.

huangapple
  • 本文由 发表于 2023年6月11日 22:30:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450964.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定