Skip to content

Proguard will remove SwingDispatcherFactory (MainDispatcherFactory) on JVM #4025

Open
@mikedawson

Description

@mikedawson

Describe the bug

If you use Proguard on JVM (e.g. as part of a Compose/Desktop application as per compose docs), then the MainDispatcherFactory is removed. When the application runs, it crashes because there is no main dispatcher.

The following Proguard rules are required:

-keep class kotlinx.coroutines.internal.MainDispatcherFactory { *; }
-keep class kotlinx.coroutines.swing.SwingDispatcherFactory { *; }

Proguard on Desktop/JVM doesn't have automatic rule consumption like Android, so documenting the requirement e.g. here https://github.com/Kotlin/kotlinx.coroutines#r8-and-proguard is critical.

Provide a Reproducer

This can be reproduced from this branch of our code:
https://github.com/UstadMobile/UstadMobile/tree/dev-desktop-conveyor

Remove the above lines from app-desktop/compose-desktop.pro , and the crash will be observed.

Alternatively:

  1. Create a new Compose JVM/Desktop app
  2. Enable obfuscation as per compose docs)
  3. Run it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsKDoc and API reference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions