gpt4 book ai didi

java - android项目中不同的kotlin版本

转载 作者:行者123 更新时间:2023-12-03 04:54:09 24 4
gpt4 key购买 nike

如果我在项目和该项目的依赖项中有不同的 Kotlin 版本,我无法弄清楚我会遇到什么问题。
选项1:

  • 项目包括 Kotlin 1.3.72
  • 一些库(例如 okhttp)包括 Kotlin 1.4.10 . (我们现在将 Kotlin 1.4.x 功能接口(interface)用于 Authenticator、Interceptor 等。)

  • 选项 2:
  • 项目包括 Kotlin 1.4.0
  • 一些库包括 Kotlin 1.3.71

  • 在选项 2 中,我收到下一个警告:
    w:类路径中的运行时 JAR 文件应该具有相同的版本。这些文件在类路径中找到:
    /.gradle/caches/transforms-2/files-2.1/ab41544fa06f7b55dec847efe3b9899c/jetified-kotlin-stdlib-jdk7-1.3.71.jar(1.3版)
    .gradle/caches/transforms-2/files-2.1/a4c6c3b949eb40b555dea1468ae75f87/jetified-kotlin-stdlib-1.4.10.jar(1.4版)
    .gradle/caches/transforms-2/files-2.1/f98f62bf33e752598311020043618780/jetified-kotlin-stdlib-common-1.4.10.jar(1.4版)
    w:类路径中的某些运行时 JAR 文件的版本不兼容。考虑将它们从类路径中删除

    最佳答案

    /.gradle/caches/transforms-2/files-2.1/ab41544fa06f7b55dec847efe3b9899c/jetified-kotlin-stdlib-jdk7-1.3.71.jar(1.3版)
    这可以通过将其包含在您的应用程序 build.gradle 依赖项中来解决:

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    另外,我个人学会了添加以下依赖项来避免这些错误:
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    另外,请确保您拥有 ext.kotlin_version = "1.4.10"在你的项目 build.gradle

    关于java - android项目中不同的kotlin版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64239149/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com