3

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 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

@Dimitri Thanks a lot. This solved the problem completely.
One problem while running this: fun main() { GlobalScope.launch { delay(1000L) println("World!") } println("Hello,") Thread.sleep(2000L) //No Thread!! } No Thread found in package.... unresolved reference....
Seems no kotlin.concurrent package is found here also!!
yes, concurrent is only available for JVM at this time. kotlinlang.org/api/latest/jvm/stdlib - scroll down to concurrent and you will see the green circle only (JVM)
Yes, can see now. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.