I've specified the following in my project:
Module
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version'
}
Project
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Wrapper
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Gradle sync completes without errors, however each of my calls to
GlobalScope.launch {}
'launch' is marked with the following error:
'Unsupported [cannot use release coroutines with api version less than 1.3]'
I've invalidated and clean rebuilt - what am I missing?
**Edit
I can see where the error is generated:
kotlin/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/coroutineCallChecker.kt
fun checkCoroutinesFeature(languageVersionSettings: LanguageVersionSettings, diagnosticHolder: DiagnosticSink, reportOn: PsiElement) {
if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)) {
if (languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3) {
diagnosticHolder.report(Errors.UNSUPPORTED.on(reportOn, "cannot use release coroutines with api version less than 1.3"))
}
return
}
Coroutines were already available in previous Kotlin releases, but version 1.3 makes them stable, meaning that their API will not change in future releases.
UPDATE: Kotlin coroutines are no longer experimental as of Kotlin 1.3. Kotlin coroutines can and should be used in production. That was the chief reason to officially release them in Kotlin 1.1.
Coroutines have been with us since Kotlin 1.1 as an experimental feature. But Kotlin 1.3 released the final API, and now they are production ready.
Kotlin's Coroutines enabling you to write parallel code easily, in a sequential way, and without worrying about the contextual overheads you know from using threads in Java.
You're missing the standard library in your dependencies. The plugin inspects that to figure out what version of the api to use.
Add "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
as a dependency to fix your error.
Right click on project name -> Maven -> Reimport. In my case it has helped.
What worked for me with IntelliJ 2019.2.1 + Gradle
File => Project Structure
Then from the Project Settings Dialog select Modules
and for each Kotlin module ensure the Language version and the API version matches. Unfortunately these settings get reset after every Gradle sync so you have to repeat the process after every Gradle sync.
**.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With