【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中指定的版本。
相关推荐
m0_740154671 分钟前
Tomcat
java·tomcat
爱敲代码的小冰8 分钟前
【Excel】 Power Query抓取多页数据导入到Excel
android·java·excel
心流时间22 分钟前
[Java基础] JVM常量池介绍(BeanUtils.copyProperties(source, target)中的属性值引用的是同一个对象吗)
java·开发语言·jvm
瑞金彭于晏39 分钟前
通俗易懂版 Maven 科普,maven是什么?
java·maven
好看资源平台43 分钟前
Java Web开发实战与项目——Spring Boot与Spring Cloud微服务项目实战
java
.猫的树1 小时前
Java集合List快速实现重复判断的10种方法深度解析
java·开发语言·list·集合
littlegirll1 小时前
命令行方式安装KFS同步KES到KADB
java·大数据·数据库
itachi-uchiha1 小时前
深入理解 Linux 中的 last 和 lastb 命令
java·linux·服务器
xiaoyustudiowww1 小时前
JSP + Servlet 实现 AJAX(纯JS版)
java·javascript·servlet
计算机毕设定制辅导-无忧学长1 小时前
Maven 插件的使用(一)
java·python·maven