返回排行榜

Kotlin/kotlinx.coroutines

Kotlin

Library support for Kotlin coroutines

kotlincoroutinesasync
Star 增长趋势
Star
13.8k
Forks
1.9k
周增长
Issues
294
5k10k
2016年7月2019年11月2023年3月2026年7月
README

kotlinx.coroutines

Kotlin Stable JetBrains official project GitHub license Download Kotlin KDoc link Slack channel

Library support for Kotlin coroutines with multiplatform support. This is a companion version for the Kotlin 2.2.20 release.

suspend fun main() = coroutineScope {
    launch { 
       delay(1.seconds)
       println("Kotlin Coroutines World!") 
    }
    println("Hello")
}

Play with coroutines online here

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.11.0</version>
</dependency>

And make sure that you use the latest Kotlin version:

<properties>
    <kotlin.version>2.2.20</kotlin.version>
</properties>

Gradle

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

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

And make sure that you use the latest Kotlin version:

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

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

repositories {
    mavenCentral()
}

Android

Add kotlinx-coroutines-android module as a dependency when using kotlinx.coroutines on Android:

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

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

R8 and ProGuard

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

Avoiding including the debug infrastructure in the resulting APK

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

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

Multiplatform

Core modules of kotlinx.coroutines are also available for Kotlin/JS and Kotlin/Native.

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

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

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

JS

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

Native

Kotlin/Native version of kotlinx.coroutines is published as kotlinx-coroutines-core-$platform where $platform is the target Kotlin/Native platform. Targets are provided in accordance with official K/N target support.

Building and Contributing

See Contributing Guidelines.

相关仓库
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
JetBrains/kotlin

The Kotlin Programming Language.

Kotlinkotlinprogramming-language
kotlinlang.org
53.2k6.4k
lysine-dev/okhttp

A meticulous HTTP client for the JVM, Android, and GraalVM.

KotlinApache License 2.0javaandroid
lysine.dev/okhttp/
47k9.3k
square/okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

KotlinApache License 2.0javaandroid
square.github.io/okhttp/
46.2k9.2k
gkd-kit/gkd

基于无障碍,高级选择器,订阅规则的自定义屏幕点击安卓应用 | An Android APP with custom screen tapping based on Accessibility, Advanced Selectors, and Subscription Rules

KotlinGNU General Public License v3.0androidkotlin
gkd.li
40.3k1.9k
yuliskov/SmartTube

Browse media content with your own rules on Android TV

JavaMavenMIT Licenseandroidandroid-tv
smarttubeapp.github.io
31.4k1.8k
square/leakcanary

A memory leak detection library for Android.

KotlinApache License 2.0androidmemory-leak
square.github.io/leakcanary
29.9k4k
JunkFood02/Seal

🦭 Video/Audio Downloader for Android, based on yt-dlp

KotlinGNU General Public License v3.0androidjetpack-compose
27.7k1.3k
NativeScript/NativeScript

⚡ Write Native with TypeScript ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Flutter and you name it compatible.

TypeScriptnpmMIT Licensenativescriptandroid
nativescript.org
25.6k1.7k
mihonapp/mihon

Free and open source manga reader for Android

KotlinApache License 2.0androidkotlin
22.2k1.3k
google/iosched

The Google I/O Android App

KotlinApache License 2.0kotlinarchitecture
21.6k6.1k
android/nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose

KotlinApache License 2.0androidjetpack-compose
21.6k4.5k