- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 265字
- 2021-08-05 10:46:46
Adding support for coroutines
Now that the project has been created, it's time to add coroutines support. To do this, open the Project section and double-click in build.gradle for the project. It is located inside the Gradle Scripts section:

Inside this document, you will add a new variable to centralize the coroutines version. In a new line below ext.kotlin.version, add ext.coroutines_version, as shown here, for example:
buildscript {
ext.kotlin_version = '1.2.50'
ext.coroutines_version = '0.23.3'
...
}
Now you need to add the dependencies for coroutines. Append the dependency configuration in the build.gradle file for the Module:

First, we will add the dependency for coroutines:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-
jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-
core:$coroutines_version"
<...>
}
Currently, coroutines are considered an experimental feature. In order to remove any warning when compiling or running apps using coroutines, it's necessary to also append this to the build.gradle file for the Module:
kotlin {
experimental {
coroutines "enable"
}
}
- Python概率統(tǒng)計(jì)
- Visual Basic 6.0程序設(shè)計(jì)計(jì)算機(jī)組裝與維修
- DevOps入門與實(shí)踐
- Easy Web Development with WaveMaker
- Bootstrap 4:Responsive Web Design
- Scala Reactive Programming
- RealSenseTM互動(dòng)開(kāi)發(fā)實(shí)戰(zhàn)
- Node.js開(kāi)發(fā)指南
- Learning Hadoop 2
- JBoss:Developer's Guide
- Natural Language Processing with Python Quick Start Guide
- Python Linux系統(tǒng)管理與自動(dòng)化運(yùn)維
- CryENGINE Game Programming with C++,C#,and Lua
- Android應(yīng)用開(kāi)發(fā)攻略
- Manage Your SAP Projects with SAP Activate