【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中指定的版本。
相关推荐
小池先生9 分钟前
springboot启动不了 因一个spring-boot-starter-web底下的tomcat-embed-core依赖丢失
java·spring boot·后端
CodeClimb12 分钟前
【华为OD-E卷-木板 100分(python、java、c++、js、c)】
java·javascript·c++·python·华为od
odng15 分钟前
IDEA自己常用的几个快捷方式(自己的习惯)
java·ide·intellij-idea
CT随23 分钟前
Redis内存碎片详解
java·开发语言
brrdg_sefg32 分钟前
gitlab代码推送
java
hanbarger1 小时前
mybatis框架——缓存,分页
java·spring·mybatis
小白学大数据1 小时前
高级技术文章:使用 Kotlin 和 Unirest 构建高效的 Facebook 图像爬虫
爬虫·数据分析·kotlin
cdut_suye1 小时前
Linux工具使用指南:从apt管理、gcc编译到makefile构建与gdb调试
java·linux·运维·服务器·c++·人工智能·python
苹果醋31 小时前
2020重新出发,MySql基础,MySql表数据操作
java·运维·spring boot·mysql·nginx
小蜗牛慢慢爬行1 小时前
如何在 Spring Boot 微服务中设置和管理多个数据库
java·数据库·spring boot·后端·微服务·架构·hibernate