Kotlin native error unresolved reference coroutines

断了今生、忘了曾经 提交于 2021-02-08 08:59:18

问题


I'm trying to build a native in Windows.

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

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'
    }

}

This dependency line gives error:

dependencies {
        implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
    }

The error is:

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.

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

Appreciate some help on this.

Thanks


回答1:


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

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

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



来源:https://stackoverflow.com/questions/61560753/kotlin-native-error-unresolved-reference-coroutines

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