Kotlin本机错误未解析的引用协程
我正在尝试在Windows中构建本机 我不确定实现“org.jetbrains.kotlinx:kotlinx coroutines core:1.3.5”的依赖关系放在哪里 我当前的gradle文件如下所示:Kotlin本机错误未解析的引用协程,kotlin,kotlin-coroutines,Kotlin,Kotlin Coroutines,我正在尝试在Windows中构建本机 我不确定实现“org.jetbrains.kotlinx:kotlinx coroutines core:1.3.5”的依赖关系放在哪里 我当前的gradle文件如下所示: buildscript { ext.kotlin_version = '1.3.72' repositories { mavenCentral() } dependencies { classpath("org.jetbr
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
}
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
}
repositories {
mavenCentral()
jcenter()
}
kotlin {
mingwX64("mingw") {
binaries {
executable {
// Change to specify fully qualified name of your application's entry point:
entryPoint = 'sample.main'
// Specify command-line arguments, if necessary:
runTask?.args('')
}
}
}
sourceSets {
mingwMain {
}
mingwTest {
}
}
experimental {
coroutines 'enable'
}
}
此依赖项行显示错误:
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
}
错误是:
Could not find method implementation() for arguments [org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
如果删除该依赖项,如果尝试导入kotlinx.coroutines.*和kotlin.concurrent.thread,则会得到“未解析引用”
谢谢你在这方面的帮助
谢谢org.jetbrains.kotlinx:kotlinx coroutines core native 也 Kotlin/Native仅支持Gradle版本4.10,您需要在settings.Gradle文件中启用Gradle元数据: enableFeaturePreview('GRADLE\u元数据') 由于Kotlin/Native通常不提供版本之间的二进制兼容性,因此您应该使用与构建kotlinx.coroutines时使用的相同版本的Kotlin/Native编译器
@Dimitri非常感谢。这完全解决了问题。运行此程序时出现一个问题:fun main(){GlobalScope.launch{delay(1000L)println(“World!”)}println(“Hello,”)Thread.sleep(2000L)//无线程!!}包中未找到线程。。。。未解析的引用…此处似乎也找不到kotlin.concurrent包!!是的,目前仅对JVM可用并发。-向下滚动到concurrent,您将看到绿色圆圈(JVM)是的,现在可以看到。谢谢