Desktop Build
Stoat for Android has an experimental desktop build. It runs the shared Compose Multiplatform code on the JVM, so you get the same screens as on Android in a desktop window.
Turning it on
Section titled “Turning it on”The desktop target is opt-in, so it never slows down mobile builds. Pass -Pstoat.desktop=true to
Gradle to add the jvm() targets to :core:api, :core:designsystem and :shared, and to include
the :desktop module.
To see :desktop in Android Studio, add this line to your user-level ~/.gradle/gradle.properties
and sync:
stoat.desktop=trueRunning
Section titled “Running”You need JDK 17 or newer. The JDK that builds the Android app works.
./gradlew -Pstoat.desktop=true :desktop:runThe first run takes a few minutes while Gradle builds the JVM variants of each module.
Currently, you must log in with an existing account.
Registration needs an hCaptcha challenge, which the desktop build will not show yet.
The app keeps its database and settings in your user data folder:
| OS | Folder |
|---|---|
| Linux | $XDG_DATA_HOME/Stoat or ~/.local/share/Stoat |
| macOS | ~/Library/Application Support/Stoat |
| Windows | %APPDATA%\Stoat |
Delete the folder to log out and start fresh.
Packaging a jar
Section titled “Packaging a jar”To build a single jar you can run with java -jar:
./gradlew -Pstoat.desktop=true :desktop:packageUberJarForCurrentOSGradle writes it to desktop/build/compose/jars/.
For a smaller jar, build the release variant. It runs ProGuard, since Compose Desktop doesn’t support R8:
./gradlew -Pstoat.desktop=true :desktop:packageReleaseUberJarForCurrentOSProGuard only shrinks the release jar. Its optimiser produces bytecode the JVM rejects for large
composables, so desktop/build.gradle.kts turns optimisation off. Keep rules live in
desktop/proguard-rules.pro. If the release jar crashes with a missing class, method or enum
constant that the plain jar has, the fix should be added to that file.
Both jars only run on the OS you built them on.
What works and what doesn’t
Section titled “What works and what doesn’t”| Feature | Desktop |
|---|---|
| Logging in, servers, DMs, groups | Works |
| Reading and sending messages | Works |
| Images, avatars, emoji | Works |
| Settings | Works |
| ↵ to send / ⇧↵ for newline | Works |
| Pasting files and images | Works |
| Maths rendering | Shows KaTeX source |
| Registration | Not supported (no hCaptcha webview) |
| Voice calls | No LiveKit, not supported |
| Push notifications | Not supported |
| Voice messages, recording | Not implemented |
| Audio and video playback | Opens in browser for now |
| GIFs | No video player, shows thumbnail |
| Attachments | No viewer, open in browser |
| Camera, QR scanner | Not supported |
| YouTube and Apple Music embeds | No webview, not shown |
| Discover | No webview, shows a link |
| Language picker | Always uses system language |
Adding platform code
Section titled “Adding platform code”Each expect declaration in common code needs a desktop actual in a jvmMain source set. A stub
is fine: return a default, do nothing, or open the URL in the browser. The normal Android build
doesn’t compile jvmMain, so check desktop yourself after you add an expect:
./gradlew -Pstoat.desktop=true :desktop:compileKotlinPlatform services that :app registers with Koin, such as VoiceCalls or PushNotifications,
get desktop versions in desktop/src/main/kotlin/chat/stoat/desktop/DesktopServices.kt. Register
new ones in desktopModule in Main.kt.
When a library works on Android but crashes on desktop with NoSuchMethodError or
UnsatisfiedLinkError, check whether it ships a desktop artefact built against the Compose
Multiplatform version this project uses.