Skip to content

Add Android support#136

Draft
stackotter wants to merge 15 commits intomainfrom
stackotter/android_support
Draft

Add Android support#136
stackotter wants to merge 15 commits intomainfrom
stackotter/android_support

Conversation

@stackotter
Copy link
Collaborator

@stackotter stackotter commented Jan 16, 2026

This is a WIP. I'll fill out the description once things are bit more complete.

Todo

  • Resolve Android Swift SDK path ourself, cause SwiftPM isn't good at choosing when there are multiple Android SDKs installed, and it doesn't ensure that the SDK was built with the toolchain currently being used. If we also implement Swift toolchain discovery, then we could probably automatically locate valid toolchain/Android Swift SDK combinations in most valid setups.
  • Support metadata insertion on Android (requires being able to locate SDKs ourselves).
  • APK bundling
  • Make target Android API version configurable
  • Change target architecture to match target device
  • Support multi-arch Android APK builds
  • Automatically locate compatible Swift toolchains (because Swift Android SDKs are quite particular)
  • Locate Android NDKs in ~/android-ndk or other yet unknown non-standard locations (the latter by following symlinks in the Swift Android SDK as a last resort)
  • Gracefully ignore Android platform when searching for devices with a platform hint and avdmanager can't be found. This happens when the user hasn't install the Android SDK cmdline-tools feature

Future improvements

  • Update toolchain compatibility resolution to be two-way (i.e. if you provide a toolchain but no SDK, then we should take the toolchain into account when selecting an SDK)
  • Choose between multiple matching SDKs by eliminating any that don't have a corresponding compatible toolchain installed (rather than just picking the first one)

@stackotter stackotter force-pushed the stackotter/android_support branch from a32e5a9 to cf0f10e Compare January 16, 2026 04:49
Without this, the Android build system links with the absolute path
of the file on my laptop, which of course leads to a crash when run
on my Android device.
@stackotter stackotter force-pushed the stackotter/android_support branch from b9cf70e to 195ad4e Compare February 3, 2026 03:05
Package graph loading was required to implement Java/Kotlin src
enumeration. Libraries can now have Bundler.toml files that provide
per-target Swift Bundler specific configuration (such as Java/Kotlin
source directories for Android). Target-specific configuration handling
itself isn't implemented in this commit.
This allows library targets such as SwiftCrossUI's AndroidBackend to
include the Java/Kotlin code necessary for them to function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant