When I try to compile my Android app written in Kotlin, I get the following compilation error, and my build fails:
w: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond
How can I fix this?
It turns out it is actually very easy to solve this problem, and I thought I'd document my solution for people who will undoubtedly stumble upon the same problem in the future.
Simply remove the following block from your app-level build.gradle, hit "Sync Now" in Android Studio and rebuild:
kotlin {
experimental {
coroutines "enable"
}
}
You don't need this anymore when using Kotlin 1.3 as it removed the "experimental" nature of Coroutines. See here:
Coroutines are now stable
Coroutines are a modern way to write non-blocking asynchronous code that’s easy to understand and evolve. It’s a powerful tool for anything from offloading work onto background workers to implementing complicated network protocols. The kotlinx.coroutines library hits 1.0 release and provides a solid foundation for managing asynchronous jobs at any scale including composition, cancelation, exception handling and UI-specific use cases.
You probably have a missing reference in your build script, e.g.:
kotlin {
experimental {
coroutines "enable"
}
}
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