运行本机Windows Kotlinx示例错误

时间:2020-05-02 06:18:11

标签: kotlin kotlin-coroutines

我正在尝试在Windows 10上运行此本机协程代码,并使用IntelliJ IDEA进行构建。在我的项目属性中还添加了org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5。

package sample
import kotlinx.coroutines.*

fun main() {

    GlobalScope.launch {
        delay(1000L)
        println("World!")
    }
    println("Hello,")
    Thread.sleep(2000L)
}

这是我的build.gradle:但是我不确定将依赖实现'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'放在哪里-

buildscript {
    ext.kotlin_version = '1.3.72'

    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")

    }
}

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
    //kotlin("jvm") version "1.3.72"
}
repositories {
    mavenCentral()
    jcenter()
}

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

kotlin {        
    // For Windows, should be changed to e.g. mingwX64
    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 {
        }
    }

}

我收到此错误:

...\src\mingwMain\kotlin\sample\SampleMingw.kt: (2, 16): Unresolved reference: coroutines

请帮助。

谢谢

0 个答案:

没有答案