【Android】kotlin jdk版本冲突与Kotlin依赖管理插件

1、androidx.activity:activity:1.8.0 依赖版本错误问题

*依赖项"androidx.activity:activity:1.8.0"要求依赖它的库和应用针对版本 34 或更高版本 Android API 进行编译。:app 目前是针对 android-33 编译的。此外,Android Gradle 插件 7.3.0 的最大推荐编译 SDK 版本为 33。*

复制代码
19 issues were found when checking AAR metadata:
​
  1.  Dependency 'androidx.activity:activity-ktx:1.8.0' 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-32.
​
      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.4.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
      compileSdkVerion of at least 34.
​
      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.activity:activity:1.8.0' 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-32.
​
      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.4.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
      compileSdkVerion of at least 34.
​
      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).
​
  3.  Dependency 'androidx.savedstate:savedstate-ktx:1.2.1' 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.
​
      Recommended action: Update this project to use a newer compileSdkVersion
      of at least 33, for example 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).
​
  4.  Dependency 'androidx.savedstate:savedstate:1.2.1' 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.
​
      Recommended action: Update this project to use a newer compileSdkVersion
      of at least 33, for example 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).
​
  5.  Dependency 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' 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.
​
      Recommended action: Update this project to use a newer compileSdkVersion
      of at least 33, for example 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).
​
  6.  Dependency 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' 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.
​
      Recommended action: Update this project to use a newer compileSdkVersion
      of at least 33, for example 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).
​
        .......
        .......
        .......
        .......
        .......
​
 19.  Dependency 'androidx.annotation:annotation-experimental:1.3.0' 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.
​
      Recommended action: Update this project to use a newer compileSdkVersion
      of at least 33, for example 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).
解决方式:升级编译后的sdk版本

compileSdktargetSdk 设置为34或者更高版本

以上内容已经解决了,您的问题,下面内容可忽略!!!

以上内容已经解决了,您的问题,下面内容可忽略!!!

以上内容已经解决了,您的问题,下面内容可忽略!!!

2、 Kotlin 相关依赖库的版本冲突问题

【Android】报错内容 Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

解决方式:添加Kotlin依赖管理插件 platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")

复制代码
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
复制代码
项目中引入 Kotlin 的依赖管理插件。其中 platform("org.jetbrains.kotlin:kotlin-bom:1.8.0") 的作用是引入 Kotlin 的 Bill of Materials(BOM),简化了 Kotlin 相关库的版本管理。通过引入 BOM,可以统一管理 Kotlin 相关库的版本,避免版本冲突和简化依赖配置。这样在引入其他 Kotlin 相关库时,可以不指定版本号,直接使用BOM中指定的版本。
相关推荐
武子康10 分钟前
大数据-230 离线数仓 - ODS层的构建 Hive处理 UDF 与 SerDe 处理 与 当前总结
java·大数据·数据仓库·hive·hadoop·sql·hdfs
武子康12 分钟前
大数据-231 离线数仓 - DWS 层、ADS 层的创建 Hive 执行脚本
java·大数据·数据仓库·hive·hadoop·mysql
苏-言18 分钟前
Spring IOC实战指南:从零到一的构建过程
java·数据库·spring
界面开发小八哥25 分钟前
更高效的Java 23开发,IntelliJ IDEA助力全面升级
java·开发语言·ide·intellij-idea·开发工具
草莓base39 分钟前
【手写一个spring】spring源码的简单实现--容器启动
java·后端·spring
Dnelic-43 分钟前
【单元测试】【Android】JUnit 4 和 JUnit 5 的差异记录
android·junit·单元测试·android studio·自学笔记
Allen Bright1 小时前
maven概述
java·maven
编程重生之路1 小时前
Springboot启动异常 错误: 找不到或无法加载主类 xxx.Application异常
java·spring boot·后端
薯条不要番茄酱1 小时前
数据结构-8.Java. 七大排序算法(中篇)
java·开发语言·数据结构·后端·算法·排序算法·intellij-idea
努力进修1 小时前
“探索Java List的无限可能:从基础到高级应用“
java·开发语言·list