Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7

后端 未结 15 1148
闹比i
闹比i 2020-11-30 06:17

I installed the Kotlin plugin into my app (v. v1.1.1-release-Studio2.2-1) and then selected "Configure Kotlin in Project" I selected compiler and runtime version

15条回答
  •  甜味超标
    2020-11-30 06:43

    In case a (transitive) dependency still uses the jre variant of the Kotlin library, you can force the use of the jdk variant with the help of a resolution strategy:

    configurations.all {
        resolutionStrategy {
            eachDependency { DependencyResolveDetails details ->
                details.requested.with {
                    if (group == "org.jetbrains.kotlin" && name.startsWith("kotlin-stdlib-jre")) {
                        details.useTarget(group: group, name: name.replace("jre", "jdk"), version: version)
                        details.because("Force use of 'kotlin-stdlib-jdk' in favor of deprecated 'kotlin-stdlib-jre'.")
                    }
                }
            }
        }
    }
    

提交回复
热议问题