https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

spierce7

12/11/2018, 3:02 AM
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

gildor

12/11/2018, 3:15 AM
Copy code
compileKotlin {
    kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]

}
b

bdawg.io

12/11/2018, 3:46 AM
Experimental itself is an experimental feature. So you need to add
"-Xuse-experimental=kotlin.Experimental"
too
g

gildor

12/11/2018, 3:50 AM
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

spierce7

12/11/2018, 6:20 AM
@gildor This doesn't seem to work for Android projects. The
compileKotlin
task doesn't exist. Any suggestions?
g

gildor

12/11/2018, 6:26 AM
It does. Do you use groovy?
But maybe it has different name because of flavors
d

Dico

12/11/2018, 6:27 AM
The -Xuse-experimental parameter, is that a list?
g

gildor

12/11/2018, 6:27 AM
just use
tasks.withType(KotlinCompile)
to apply to all tasks of this type
d

Dico

12/11/2018, 6:27 AM
Can I separate values by comma or something
g

gildor

12/11/2018, 6:28 AM
yes, it’s list
d

Dico

12/11/2018, 6:28 AM
Now I actually understand what it does, ty
g

gildor

12/11/2018, 6:28 AM
Copy code
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi", "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
s

spierce7

12/11/2018, 6:37 AM
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

gildor

12/11/2018, 6:38 AM
Did you import KotlinCompile?
or just use fully qualified name
org.jetbrains.kotlin.gradle.tasks.KotlinCompile
s

spierce7

12/11/2018, 6:39 AM
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

gildor

12/11/2018, 6:57 AM
Do you have this error on compile time?
s

spierce7

12/11/2018, 2:30 PM
yes
compile time is the only time I see this error
5 Views