I have this warning all over the place polluting o...
# coroutines
s
I have this warning all over the place polluting our build logs, to the point where circleci is making me download our build logs because they are too long:
This declaration is experimental and its usage should be marked with '@kotlinx.coroutines.ExperimentalCoroutinesApi'
Is there a way I can declare that we are using experimental coroutines api in the
build.gradle
, and thus get rid of all these warnings everywhere? Or am I forced to go to every file, and explicitly annotate it?
g
Copy code
compileKotlin {
    kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]

}
b
Experimental itself is an experimental feature. So you need to add
"-Xuse-experimental=kotlin.Experimental"
too
g
No, you don’t need it in this case, only if you want to have own experimental annotation and don’t want to have warnings
👍 1
s
@gildor This doesn't seem to work for Android projects. The
compileKotlin
task doesn't exist. Any suggestions?
g
It does. Do you use groovy?
But maybe it has different name because of flavors
d
The -Xuse-experimental parameter, is that a list?
g
just use
tasks.withType(KotlinCompile)
to apply to all tasks of this type
d
Can I separate values by comma or something
g
yes, it’s list
d
Now I actually understand what it does, ty
g
Copy code
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi", "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
s
hmmmm. Still didn't work.
Copy code
tasks.withType(KotlinCompile) {
        kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
    }
Could not get unknown property 'KotlinCompile' for project ':actions-android' of type org.gradle.api.Project.
g
Did you import KotlinCompile?
or just use fully qualified name
org.jetbrains.kotlin.gradle.tasks.KotlinCompile
s
I didn't. That was going to be my next question. what's the full qualified name
thanks
@gildor I'm seeing this error now:
e: Experimental API marker kotlinx.coroutines.ExperimentalCoroutinesApi is unresolved. Please make sure it's present in the module dependencies
g
Do you have this error on compile time?
s
yes
compile time is the only time I see this error