Kotlin本机错误未解析的引用协同程序



我正在尝试在Windows中构建一个本机。

我不确定实现的依赖关系放在哪里"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"。

我当前的渐变文件如下所示:

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.current.thread ,就会得到"未解析引用">

感谢在这方面的帮助。

感谢

org.jetbrains.kotlinx:kotlinx协同程序核心原生

此外Kotlin/Native仅支持Gradle版本4.10,您需要在设置中启用Gradle元数据。Gradle文件:

enableFeaturePreview('GRADLE_METADATA'(由于Kotlin/Native通常不提供版本之间的二进制兼容性,因此您应该使用与用于构建Kotlin.coroutines相同版本的Kotlin/Native编译器。

https://github.com/Kotlin/kotlinx.coroutines/blob/master/README.md

最新更新