Closed pauliusrum closed 5 years ago
Did you reimport your Gradle project into IDEA?
Yes. This happened after i updated kotlin to 1.3.20
and the kotlin compiler plugin.
We also have a multiplatform project with these settings:
all {
languageSettings {
useExperimentalAnnotation 'kotlin.contracts.ExperimentalContracts'
useExperimentalAnnotation 'kotlinx.coroutines.ExperimentalCoroutinesApi'
useExperimentalAnnotation 'kotlinx.coroutines.ObsoleteCoroutinesApi'
useExperimentalAnnotation 'kotlinx.serialization.ImplicitReflectionSerializer'
}
}
In that project the idea will not show the warnings anymore.
Can you share some more details? I cannot reproduce it with 1.3.20 on the minimal test project that I have.
build.gradle:
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
}
group 'example'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs = ['-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer,kotlinx.coroutines.ObsoleteCoroutinesApi']
}
main.kt
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.runBlocking
fun main() = runBlocking {
Channel<Int>().consumeEach { }
}
@pauliusrum
Make sure to use +=
instead of =
each time you want to define compiler arguments with freeCompilerArgs
. Otherwise one gradle script might override the compiler arguments set by another script.
Removing this line from gradle.properties helped:
kotlin.parallel.tasks.in.project=true
I've reported this issue to Kotlin gradle plugin: https://youtrack.jetbrains.com/issue/KT-29928
for me works like this
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += [
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi"]
}
@evansgelist , thanks. Your solution works like a charm.
@since 1.3.70
use -Xopt-in
to replace -Xuse-experimental
// Groovy DSL
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += [
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.OptIn"
]
}
}
// Kotlin DSL
tasks.withType<KotlinCompile>().all {
kotlinOptions.freeCompilerArgs += listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.OptIn"
)
}
when I use what @mochadwi said, I get > Task :texts:impl:compileDebugKotlin w: Class kotlin.OptIn is not an opt-in requirement marker
˙. What does it mean? Is OptIn hooked up implicitly?
for me works like this
kotlinOptions { jvmTarget = "1.8" freeCompilerArgs += [ "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi"] }
In which file within the FLutter application ??
Change to the distributionUrl in /android/gradle/wrapper/gradle-wrapper.properties fixed the issue for me.
distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip
Hello,
I have added kotlin experimental features compiler flag to my build.gradle but i still get the warning shown in idea. What i am doing wrong?