本文介绍了Kotlin本机错误未解决的参考协程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows中构建本机.

I'm trying to build a native in Windows.

我不确定将实现"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"的依赖项放在何处.

I'm not sure where to put the dependency for implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'.

我当前的gradle文件如下:

My current gradle file looks like this:

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,则会得到未解析的引用"

If I remove that dependency, I get "unresolved Reference" if I try to import kotlinx.coroutines.* and kotlin.concurrent.thread

对此有所帮助.

谢谢

推荐答案

org.jetbrains.kotlinx:kotlinx-coroutines-core-native

org.jetbrains.kotlinx:kotlinx-coroutines-core-native

也Kotlin/Native仅支持Gradle 4.10版,您需要在settings.gradle文件中启用Gradle元数据:

alsoKotlin/Native supports only Gradle version 4.10 and you need to enable Gradle metadata in your settings.gradle file:

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

enableFeaturePreview('GRADLE_METADATA')Since Kotlin/Native does not generally provide binary compatibility between versions, you should use the same version of Kotlin/Native compiler as was used to build kotlinx.coroutines.

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

这篇关于Kotlin本机错误未解决的参考协程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 03:52