Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Library support for Kotlin coroutines

License

NotificationsYou must be signed in to change notification settings

Kotlin/kotlinx.coroutines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kotlin StableJetBrains official projectGitHub licenseDownloadKotlinKDoc linkSlack channel

Library support for Kotlin coroutines withmultiplatform support.This is a companion version for the Kotlin2.0.0 release.

suspendfunmain()= coroutineScope {    launch {        delay(1000)println("Kotlin Coroutines World!")     }println("Hello")}

Play with coroutines onlinehere

Modules

Documentation

Using in your projects

Maven

Add dependencies (you can also add other modules that you need):

<dependency>    <groupId>org.jetbrains.kotlinx</groupId>    <artifactId>kotlinx-coroutines-core</artifactId>    <version>1.10.1</version></dependency>

And make sure that you use the latest Kotlin version:

<properties>    <kotlin.version>2.0.0</kotlin.version></properties>

Gradle

Add dependencies (you can also add other modules that you need):

dependencies {    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")}

And make sure that you use the latest Kotlin version:

plugins {// For build.gradle.kts (Kotlin DSL)    kotlin("jvm") version"2.0.0"// For build.gradle (Groovy DSL)    id"org.jetbrains.kotlin.jvm" version"2.0.0"}

Make sure that you havemavenCentral() in the list of repositories:

repositories {    mavenCentral()}

Android

Addkotlinx-coroutines-androidmodule as a dependency when usingkotlinx.coroutines on Android:

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")

This gives you access to the AndroidDispatchers.Maincoroutine dispatcher and also makes sure that in case of a crashed coroutine with an unhandled exception thatthis exception is logged before crashing the Android application, similarly to the way uncaught exceptions inthreads are handled by the Android runtime.

R8 and ProGuard

R8 and ProGuard rules are bundled into thekotlinx-coroutines-android module.For more details see"Optimization" section for Android.

Avoiding including the debug infrastructure in the resulting APK

Thekotlinx-coroutines-core artifact contains a resource file that is not required for the coroutines to operatenormally and is only used by the debugger. To exclude it at no loss of functionality, add the following snippet to theandroid block in your Gradle file for the application subproject:

packagingOptions {    resources.excludes+="DebugProbesKt.bin"}

Multiplatform

Core modules ofkotlinx.coroutines are also available forKotlin/JS andKotlin/Native.

In common code that should get compiled for different platforms, you can add a dependency tokotlinx-coroutines-core right to thecommonMain source set:

commonMain {    dependencies {        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")    }}

Platform-specific dependencies are recommended to be used only for non-multiplatform projects that are compiled only for target platform.

JS

Kotlin/JS version ofkotlinx.coroutines is published askotlinx-coroutines-core-js(follow the link to get the dependency declaration snippet).

Native

Kotlin/Native version ofkotlinx.coroutines is published askotlinx-coroutines-core-$platform where$platform isthe target Kotlin/Native platform.Targets are provided in accordance withofficial K/N target support.

Building and Contributing

SeeContributing Guidelines.


[8]ページ先頭

©2009-2025 Movatter.jp