2

I'm trying to run a native Kotlin project using coroutines using IntelliJ IDEA Community 2020.

Here is how my build.gradle looks:

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
}

repositories {
    mavenCentral()
}

kotlin {
    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // 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 {
        // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
        // in gradle.properties file and re-import your project in IDE.
        mingwMain {
        }
        mingwTest {
        }
    }

}

// Use the following Gradle tasks to run your application:
// :runReleaseExecutableMingw - without debug symbols
// :runDebugExecutableMingw - with debug symbols

And here is a simple KT file:

package sample

import kotlinx.coroutines.*

fun main() = runBlocking<Unit> {

    val deferred = async(Dispatchers.Unconfined, CoroutineStart.LAZY) {
        println("Running Async Unconfined: on thread ${Thread.currentThread().name} has run.")
        42
    }

    val result = deferred.await()
    println("Async Unconfined Result is ${result}")

}

I installed the maven plugin under Project Structure | Module and screenshot attached.

enter image description here

Nevertheless, I'm getting "Unresolved References..." error. Attached screenshot...

enter image description here

Request if someone can help me to resolve this please?

Thanks

Community
  • 1
  • 1
Prana
  • 693
  • 1
  • 7
  • 16

1 Answers1

0

In your Project Structure > Modules > Dependencies tab, you selected Runtime as the scope, which makes the dependency only available at runtime (usually used for transitive dependencies). Try selecting Compile here.

theincxption
  • 189
  • 1
  • 2
  • 7