llms.txt: machine-readable documentation index. Markdown version of this page is also available.

Kotlin 语言参考文档 中文版 Help

调试协程

调试使用协程的应用程序是很困难的, 因为多个协程可以并发运行, 在一个线程上挂起, 然后在另一个线程上恢复. 它们的执行顺序和使用的线程也可能在每次运行时发生变化, 因此很难追踪某个特定协程的执行过程.

在 JVM 上, 你可以使用以下功能, 让协程调试变得容易一些:

  • 调试模式, 为每个协程添加唯一的名称, 让你在调试器和诊断输出中能够识别协程.

  • 栈追踪恢复, 当协程未能得到预期结果, 而是收到异常时, 添加异常的位置信息.

  • 调试代理, 追踪活跃的协程, 报告它们的状态信息, 等等.

调试模式和栈追踪恢复由 kotlinx-coroutines-core 模块提供. 调试代理由 kotlinx-coroutines-debug 模块提供.

启用调试模式

调试模式会为每个启动的协程分配唯一的名称. 你可以在 Java 调试器中, 协程的字符串表示中, 以及运行该协程时的线程名称中看到协程名称. 调试模式的运行时开销小到可以忽略不计, 因此可以持续启用, 以简化日志信息和问题诊断.

如果运行代码时启用了 Java 断言, kotlinx.coroutines 库会自动启用调试模式. 单元测试运行时会默认启用断言, 因此不需要明确的为它们启用调试模式.

要明确的启用调试模式, 请配置构建工具, 例如 Gradle 或 Maven, 或 IDE 的运行配置, 将参数 -Dkotlinx.coroutines.debug 传递给运行应用程序的 JVM.

在 IntelliJ IDEA 中, 启用调试模式的步骤如下:

  1. 在 Run widget 中, 选择要更新的运行/调试配置, 然后选择 More Actions | Edit:

    在 IntelliJ IDEA 中, 从运行配置的 More Actions 菜单选择 Edit

  2. 在 Run/Debug Configurations 对话框中, 在 VM options 项目中输入 -Dkotlinx.coroutines.debug, 然后点击 OK:

    在 IntelliJ IDEA 中, 向运行/调试配置添加 -Dkotlinx.coroutines.debug 选项

栈追踪恢复

当一个协程通过 Deferred.await() 等挂起函数收到另一个协程抛出的异常时, 异常的栈追踪中不会包含收到异常的协程的堆栈帧(stack frame). 缺少这些堆栈帧, 栈追踪就无法显示 Deferred.await() 被调用的位置, 也无法显示哪些函数导致了这次调用, 因而增加了调试的困难.

kotlinx.coroutines 库通过 栈追踪恢复 添加这些信息: 它会创建异常的副本, 其中添加了额外的堆栈帧.

收到异常的协程恢复运行时, 会抛出这个副本异常, 而不是原始异常. 原始异常会成为副本的原因异常. 如果原始异常带有被抑制的异常, 它们仍然附加在原始异常上, 而不会被复制. 这样可以避免异常链中出现循环, 以及在某些框架中发生崩溃.

调试模式默认会启用栈追踪恢复. 要在调试模式下禁用栈追踪恢复, 请传递 VM 选项 -Dkotlinx.coroutines.stacktrace.recovery=false.

下面的示例演示启用和禁用栈追踪恢复时的栈追踪之间的区别:

import kotlinx.coroutines.* object UserProfileService : CoroutineScope by CoroutineScope(CoroutineName("UserProfileService")) { private fun parseUserProfile(): String { error("Invalid user profile") } private fun loadUserProfile(): String { return parseUserProfile() } // 在调用这个函数的协程中运行 suspend fun awaitUserProfile() { // 启动一个新协程 val userProfile = async(Dispatchers.Default) { // 新协程抛出异常 loadUserProfile() } // 运行 awaitUserProfile() 的协程 // 通过 await() 函数收到异常 userProfile.await() } } suspend fun main() { UserProfileService.awaitUserProfile() }

在这个示例中, parseUserProfile() 函数在由 .async() 构建器函数启动的协程中抛出异常. 调用 awaitUserProfile() 的协程通过 Deferred.await() 函数收到这个异常.

禁用栈追踪恢复时, 栈追踪会显示 parseUserProfile() 在由 .async() 函数创建的协程中抛出异常的位置, 但不会包含 awaitUserProfile() 函数中的 Deferred.await() 调用:

异常栈追踪, 不包含收到异常的协程的堆栈帧

启用栈追踪恢复时, 栈追踪还会包含 awaitUserProfile() 函数中的 Deferred.await() 调用:

恢复后的异常栈追踪, 包含收到异常的协程的堆栈帧

对自定义异常的栈追踪恢复

如果异常类具有 public 的构造器, 并且这个构造器接受消息, 原因异常, 或者二者都有, 或者不接受任何参数, 栈追踪恢复就能够自动复制这个异常.

如果你希望 kotlinx.coroutines 库恢复需要额外的构造器参数的异常的栈追踪, 例如, 需要行号或错误号的异常, 请实现 StackTraceRecoverable 接口.

StackTraceRecoverable 接口是 Kotlin 标准库的一部分, 因此实现它不需要添加对 kotlinx.coroutines 库的依赖项.

要实现这个接口, 请覆盖 copyForStackTraceRecovery() 函数. 在覆盖函数中, 返回一个新的异常实例, 用于栈追踪恢复; 或者, 如果你不想让 kotlinx.coroutines 库复制异常, 则返回 null.

这些 API 是 实验性功能, 需要使用 @OptIn(ExperimentalStdlibCoroutineSupportApi::class) 注解表示使用者同意.

下面是一个自定义异常的示例, 在为栈追踪恢复功能创建新的实例时, 它会保留一个 line 属性:

import kotlinx.coroutines.* import kotlin.coroutines.ExperimentalStdlibCoroutineSupportApi import kotlin.coroutines.debug.StackTraceRecoverable @OptIn(ExperimentalStdlibCoroutineSupportApi::class) class FileEditException // 这个实现需要一个 private 构造器 // 来将 cause 传递给 IllegalStateException 构造器 private constructor( val line: Int, private val detail: String, cause: Throwable?, ) : IllegalStateException("When editing line $line: $detail", cause), // 实现 StackTraceRecoverable, 用于栈追踪恢复 StackTraceRecoverable<FileEditException> { constructor(line: Int, detail: String) : this(line, detail, null) // 复制行号, 和详细的错误消息 override fun copyForStackTraceRecovery(): FileEditException = FileEditException(line, detail, this) } private fun editFile() { throw FileEditException(15, "Unexpected token") } suspend fun main() { supervisorScope { // 启动一个新协程 val fileEdit = async(Dispatchers.Default) { // 抛出原始异常 editFile() } // 栈追踪恢复会创建异常的副本, // 添加调用协程的堆栈帧, 然后抛出副本 fileEdit.await() } }

启用调试模式后, 输出会先显示恢复后的副本, 然后显示作为其原因异常的原始异常.

Exception in thread "main" com.example.FileEditException: When editing line 15: Unexpected token at com.example.RecoveryExampleKt.editFile(RecoveryExample.kt:54) at com.example.RecoveryExampleKt.access$editFile(RecoveryExample.kt:1) at com.example.RecoveryExampleKt$main$2$fileEdit$1.invokeSuspend(RecoveryExample.kt:62) at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:42) at com.example.RecoveryExampleKt$main$2.invokeSuspend(RecoveryExample.kt:67) Caused by: com.example.FileEditException: When editing line 15: Unexpected token at com.example.RecoveryExampleKt.editFile(RecoveryExample.kt:54) at com.example.RecoveryExampleKt.access$editFile(RecoveryExample.kt:1) at com.example.RecoveryExampleKt$main$2$fileEdit$1.invokeSuspend(RecoveryExample.kt:62) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:807) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)

调试代理

kotlinx-coroutines-debug 模块为 JVM 应用程序提供了调试代理. 代理会追踪协程的创建, 挂起和恢复.

DebugProbes API 是调试代理的主要入口. 你可以用它打印活跃的协程及其当前状态. 输出包含栈追踪, 用来显示每个协程的创建位置, 以及挂起位置. 你还可以用它打印特定 Job 或 CoroutineScope 层级结构的协程转储信息.

如果在生产环境中启用 DebugProbes, 它在为每个新协程创建栈追踪时, 可能显著的降低应用程序性能. 为了避免这种开销, 请将 DebugProbes.enableCreationStackTraces 设置为 false.

添加调试代理依赖项

要在项目中使用调试代理, 请添加 kotlinx-coroutines-debug 依赖项:

// build.gradle.kts dependencies { testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.11.0") }
<!-- pom.xml --> <dependency> <groupId>org.jetbrains.kotlinx</groupId> <artifactId>kotlinx-coroutines-debug</artifactId> <version>1.11.0</version> <scope>test</scope> </dependency>

使用调试代理追踪协程

要让调试代理开始追踪协程, 可以选择以下任何一种方式:

  • 在 VM 选项中添加 -javaagent:/path/to/kotlinx-coroutines-debug-1.11.0.jar, 在应用程序启动时加载调试代理.

  • 在启动要追踪的协程之前, 调用 DebugProbes.install() 函数.

调试代理启用后, 可以使用以下 API:

下面的示例使用调试代理打印活跃的协程, 以及特定 Job 的协程层级结构:

import kotlinx.coroutines.* import kotlinx.coroutines.debug.* import kotlin.time.Duration.Companion.seconds private suspend fun loadAccount() { delay(5.seconds) } private suspend fun loadPreferences() { delay(5.seconds) } private suspend fun loadUserProfile() = coroutineScope { launch { loadAccount() } launch { loadPreferences() } } @OptIn(ExperimentalCoroutinesApi::class) fun main() { // 安装调试代理 // 只有在没有使用 -javaagent VM 选项时, 才需要这一步 DebugProbes.install() runBlocking { // 启动一个协程, 包含两个子协程 val loadingJob = launch { loadUserProfile() } // 给子协程足够的时间, 让它挂起 delay(1.seconds) // 打印所有活跃的协程 DebugProbes.dumpCoroutines() println("============") // 打印 loading job, 以及它的子协程 DebugProbes.printJob(loadingJob) } }

启用 调试模式 时, 运行这个示例会产生以下输出:

Coroutines dump 2026/08/18 14:00:08 Coroutine "coroutine#1":BlockingCoroutine{Active}@146ba0ac, state: RUNNING at java.base/java.lang.Thread.getStackTrace(Thread.java:2389) at kotlinx.coroutines.debug.internal.DebugProbesImpl.enhanceStackTraceWithThreadDumpImpl(DebugProbesImpl.kt:339) at kotlinx.coroutines.debug.internal.DebugProbesImpl.dumpCoroutinesSynchronized(DebugProbesImpl.kt:294) at kotlinx.coroutines.debug.internal.DebugProbesImpl.dumpCoroutines(DebugProbesImpl.kt:266) at kotlinx.coroutines.debug.DebugProbes.dumpCoroutines(DebugProbes.kt:181) at kotlinx.coroutines.debug.DebugProbes.dumpCoroutines$default(DebugProbes.kt:181) at DebugAgentExampleKt$main$1.invokeSuspend(DebugAgentExample.kt:34) Coroutine "coroutine#2":StandaloneCoroutine{Active}@4dfa3a9d, state: SUSPENDED at DebugAgentExampleKt$main$1$loadingJob$1.invokeSuspend(DebugAgentExample.kt:27) Coroutine "coroutine#3":StandaloneCoroutine{Active}@6eebc39e, state: SUSPENDED at DebugAgentExampleKt$loadUserProfile$2$1.invokeSuspend(DebugAgentExample.kt:14) Coroutine "coroutine#4":StandaloneCoroutine{Active}@464bee09, state: SUSPENDED at DebugAgentExampleKt$loadUserProfile$2$2.invokeSuspend(DebugAgentExample.kt:15)============ "coroutine#2":StandaloneCoroutine{Active}, continuation is SUSPENDED at line DebugAgentExampleKt$main$1$loadingJob$1.invokeSuspend(DebugAgentExample.kt:27) "coroutine#3":StandaloneCoroutine{Active}, continuation is SUSPENDED at line DebugAgentExampleKt$loadUserProfile$2$1.invokeSuspend(DebugAgentExample.kt:14) "coroutine#4":StandaloneCoroutine{Active}, continuation is SUSPENDED at line DebugAgentExampleKt$loadUserProfile$2$2.invokeSuspend(DebugAgentExample.kt:15)

你可以根据 JUnit 版本, 使用相应的 CoroutinesTimeout API, 为 JUnit 测试设置超时. 这个 API 会自动安装调试探查(debug probe). 如果测试没有在超时之前完成, 它会打印所有活跃的协程, 以及它们的栈追踪, 并让测试失败.

JUnit 4

要为 JUnit 4 测试设置超时, 并在测试超时时打印所有活跃的协程和栈追踪, 请使用 CoroutinesTimeout 规则:

import kotlinx.coroutines.* import kotlinx.coroutines.debug.junit4.CoroutinesTimeout import org.junit.Rule import org.junit.Test import kotlin.time.Duration @OptIn(ExperimentalCoroutinesApi::class) class UserProfileTest { @get:Rule val timeout = CoroutinesTimeout.seconds(1) private suspend fun loadUserProfile() { withContext(Dispatchers.IO) { // 模拟不会完成的操作 delay(Duration.INFINITE) } } @Test fun loadsUserProfile() = runBlocking { val loadingJob = launch { loadUserProfile() } // 等待协程, 让测试不会完成 loadingJob.join() } }

1 秒后, 这个规则会报告测试超时, 并打印所有活跃的协程, 以及它们的栈追踪. 之后, 测试会失败, 错误为 TestTimedOutException.

Test loadsUserProfile timed out after 1 seconds Coroutines dump 2026/08/18 13:48:21 Coroutine "coroutine#1":BlockingCoroutine{Active}@bf1ec20, state: SUSPENDED at UserProfileTest$loadsUserProfile$1.invokeSuspend(UserProfileTest.kt:27) at _COROUTINE._CREATION._(CoroutineDebugging.kt:30) at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.createCoroutineUnintercepted(IntrinsicsJvm.kt:161) at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26) at kotlinx.coroutines.BuildersKt__Builders_concurrentKt.runBlockingK$default(Builders.concurrent.kt:157) at kotlinx.coroutines.BuildersKt.runBlockingK$default(Unknown Source) at UserProfileTest.loadsUserProfile(UserProfileTest.kt:21) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutStatement$evaluate$$inlined$runWithTimeoutDumpingCoroutines$1.call(CoroutinesTimeoutImpl.kt:79) at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutStatement$evaluate$$inlined$runWithTimeoutDumpingCoroutines$1.call(CoroutinesTimeoutImpl.kt:79) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.lang.Thread.run(Thread.java:1575) Coroutine "coroutine#2":StandaloneCoroutine{Active}@70efb718, state: SUSPENDED at UserProfileTest$loadUserProfile$2.invokeSuspend(UserProfileTest.kt:16) at UserProfileTest$loadsUserProfile$1$loadingJob$1.invokeSuspend(UserProfileTest.kt:23) at _COROUTINE._CREATION._(CoroutineDebugging.kt:30) at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.createCoroutineUnintercepted(IntrinsicsJvm.kt:161) at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:200) at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source) at UserProfileTest$loadsUserProfile$1.invokeSuspend(UserProfileTest.kt:22) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at kotlinx.coroutines.BuildersKt__Builders_concurrentKt.runBlockingK$default(Builders.concurrent.kt:157) at kotlinx.coroutines.BuildersKt.runBlockingK$default(Unknown Source) at UserProfileTest.loadsUserProfile(UserProfileTest.kt:21) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutStatement$evaluate$$inlined$runWithTimeoutDumpingCoroutines$1.call(CoroutinesTimeoutImpl.kt:79) at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutStatement$evaluate$$inlined$runWithTimeoutDumpingCoroutines$1.call(CoroutinesTimeoutImpl.kt:79) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.lang.Thread.run(Thread.java:1575) test timed out after 1000 milliseconds org.junit.runners.model.TestTimedOutException: test timed out after 1000 milliseconds at java.base/jdk.internal.misc.Unsafe.park(Native Method) at java.base/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:57) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlockingImpl(Builders.kt:30) at kotlinx.coroutines.BuildersKt.runBlockingImpl(Unknown Source) at kotlinx.coroutines.BuildersKt__Builders_concurrentKt.runBlockingK(Builders.concurrent.kt:172) at kotlinx.coroutines.BuildersKt.runBlockingK(Unknown Source) at kotlinx.coroutines.BuildersKt__Builders_concurrentKt.runBlockingK$default(Builders.concurrent.kt:157) at kotlinx.coroutines.BuildersKt.runBlockingK$default(Unknown Source) at UserProfileTest.loadsUserProfile(UserProfileTest.kt:21) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutStatement$evaluate$$inlined$runWithTimeoutDumpingCoroutines$1.call(CoroutinesTimeoutImpl.kt:79) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.lang.Thread.run(Thread.java:1575)

JUnit 5

要为某个类中的所有测试函数设置超时, 请对这个类添加 @CoroutinesTimeout 注解:

import kotlinx.coroutines.* import kotlinx.coroutines.debug.junit5.CoroutinesTimeout import org.junit.jupiter.api.Test import kotlin.time.Duration @OptIn(ExperimentalCoroutinesApi::class) // 为类中的所有测试函数设置 1 秒超时 @CoroutinesTimeout(testTimeoutMs = 1_000) class UserProfileTest { private suspend fun loadUserProfile() { withContext(Dispatchers.IO) { // 模拟不会完成的操作 delay(Duration.INFINITE) } } @Test fun loadsUserProfile() = runBlocking { val loadingJob = launch { loadUserProfile() } // 等待协程, 让测试不会完成 loadingJob.join() } }

1 秒后, CoroutinesTimeout API 会报告超时, 并打印所有活跃的协程, 以及它们的栈追踪. 之后, 测试会失败, 错误为 CoroutinesTimeoutException.

Test loadsUserProfile timed out after 1 seconds Coroutines dump 2026/08/18 13:46:15 Coroutine "coroutine#1":BlockingCoroutine{Active}@5c77053b, state: SUSPENDED at UserProfileTest$loadsUserProfile$1.invokeSuspend(UserProfileTest.kt:24) Coroutine "coroutine#2":StandaloneCoroutine{Active}@26b894bd, state: SUSPENDED at UserProfileTest$loadUserProfile$2.invokeSuspend(UserProfileTest.kt:13) at UserProfileTest$loadsUserProfile$1$loadingJob$1.invokeSuspend(UserProfileTest.kt:20) test timed out after 1000 ms kotlinx.coroutines.debug.junit5.CoroutinesTimeoutException: test timed out after 1000 ms at java.base/jdk.internal.misc.Unsafe.park(Native Method) at java.base/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:57) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlockingImpl(Builders.kt:30) at kotlinx.coroutines.BuildersKt.runBlockingImpl(Unknown Source) at kotlinx.coroutines.BuildersKt__Builders_concurrentKt.runBlockingK(Builders.concurrent.kt:172) at kotlinx.coroutines.BuildersKt.runBlockingK(Unknown Source) at kotlinx.coroutines.BuildersKt__Builders_concurrentKt.runBlockingK$default(Builders.concurrent.kt:157) at kotlinx.coroutines.BuildersKt.runBlockingK$default(Unknown Source) at UserProfileTest.loadsUserProfile(UserProfileTest.kt:18) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at kotlinx.coroutines.debug.junit5.CoroutinesTimeoutExtension$interceptInvocation$$inlined$runWithTimeoutDumpingCoroutines$1.call(CoroutinesTimeoutImpl.kt:79) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.lang.Thread.run(Thread.java:1575)

解决 Android 上的 kotlinx-coroutines-debug 资源冲突

Android 环境不支持调试代理.

kotlinx-coroutines-debug 模块存在对 JNA, JNA Platform, Byte Buddy 和 Byte Buddy Agent 的传递依赖. 其中一些依赖项包含路径相同的资源. Android 在合并依赖项的资源时, 资源路径的重复可能导致 DuplicateRelativeFileException 错误, 造成构建失败.

要保留 kotlinx-coroutines-debug 依赖项目, 同时解决构建失败问题, 请在 build.gradle.kts 文件中, 使用以下 packaging 配置, 排除冲突的资源:

// build.gradle.kts android { packaging { resources { // 排除 JNA 和 JNA Platform 的许可证文件 excludes += setOf( "META-INF/AL2.0", "META-INF/LGPL2.1", ) // 排除 Byte Buddy 的 ASM 许可证文件 excludes += "META-INF/licenses/ASM" // 对每个 Byte Buddy Agent 文件, 只保留一个副本 pickFirsts += setOf( "win32-x86-64/attach_hotspot_windows.dll", "win32-x86/attach_hotspot_windows.dll", ) } } }

下一步做什么

阅读 使用 IntelliJ IDEA 调试协程 和 使用 IntelliJ IDEA 调试 Kotlin Flow, 学习在 IntelliJ IDEA 中如何调试协程.

2026/11/28