Search code examples
kotlinannotationsbuild.gradlekotlin-coroutinescoroutine

how to solve kotlin coroutine annotation warning


let me ask

I use kotlin coroutine

@OptIn(DelicateCoroutinesApi::class)
GlobalScope.launch {
    displaySura()
}

and in the build tab showing warning:

This annotation should be used with the compiler argument '-opt-in=kotlin.RequiresOptIn'

how to solve this warning? thanks in advance


Solution

  • You can add -opt-in=kotlin.RequiresOptIn compiler argument in the build file:

    compileKotlin {
        kotlinOptions {
            freeCompilerArgs += [
                    "-Xopt-in=kotlin.RequiresOptIn"
            ]
        }
    }