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

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

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 of 1.0.7. Kotlin updated my Gradle files. Now when I try to build in I get:

Error: A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApkCopy'. Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7. Required by:

MyApplication:app:unspecified

I'm not sure what I'm missing here.

回答1:

In Project level gradle use only this version

ext.kotlin_version = '1.1.1'

Remove other version



回答2:

The split of kotlin-stdlib into kotlin-stdlib-jre7 and kotlin-stdlib-jre8 was only introduced with Kotlin 1.1, that's why the dependency cannot be resolved, the package version simply does not exist.

It looks like the update to your project files failed at some point and set the Kotlin version to 1.0.7. If this is a new project and there's nothing holding you back from using 1.1.1, I'd switch to that. Your problem should be gone after doing this.



回答3:

In "build.gradle" file, change current Kotlin version that line and press synk:

ext.kotlin_version = '1.1.1' 

/// That will look like:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {     ext.kotlin_version = '1.1.1'     repositories {         jcenter()     }     dependencies {         classpath 'com.android.tools.build:gradle:2.3.0'         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"          // NOTE: Do not place your application dependencies here; they belong         // in the individual module build.gradle files     } } 


回答4:

  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" 


回答5:

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" 


回答6:

https://stackoverflow.com/a/44148210/8056898

Change Kotlin version as per your current version in system.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!