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

后端 未结 15 1029
闹比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:41

    I have solved this issue using deselection of the Offline work option in Settings

    0 讨论(0)
  • 2020-11-30 06:43
    1. Please check current version of your Kotlin in below path,

      C:\Program Files\Android\Android Studio\gradle\m2repository\org\jetbrains\kotlin\kotlin-stdlib\1.0.5

    change to that version (1.0.5) in project level gradle file.

    You can see in your above path does not mentioned any Java - jre version, so remove in your app level gradle file as below,

    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    
    0 讨论(0)
  • 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'.")
                    }
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-11-30 06:46

    Starting with Kotlin 1.1.2, the dependencies with group org.jetbrains.kotlin are by default resolved with the version taken from the applied plugin. You can provide the version manually using the full dependency notation like:

    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    

    If you're targeting JDK 7 or JDK 8, you can use extended versions of the Kotlin standard library which contain additional extension functions for APIs added in new JDK versions. Instead of kotlin-stdlib, use one of the following dependencies:

    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    
    0 讨论(0)
  • 2020-11-30 06:47

    replace

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    

    with

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    

    Since the version with jre is absolute , just replace and sync the project

    Official Documentation here Thanks for the link @ ROMANARMY

    Happy Coding :)

    0 讨论(0)
  • 2020-11-30 06:50

    build.gradle (Project)

    buildScript {
        ...
        dependencies {
            ...
            classpath 'com.android.tools.build:gradle:4.0.0-rc01'
        }
    } 
    

    gradle/wrapper/gradle-wrapper.properties

    ...
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    

    Some libraries require the updated gradle. Such as:

    androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"
    

    GL

    0 讨论(0)
提交回复
热议问题