x/mobile: Extend support for non Android java platform

176 views
Skip to first unread message

K

unread,
Feb 24, 2023, 9:11:55 PM2/24/23
to golang-nuts
Hi all,

currently "x/mobile" support Android platform by generating AAR files, it can be easily support other platforms like Desktop (Windows, Linux, MacOS) for Java/Kotlin by generating a JAR file and .(so/dll/dylib), it only need to include the right headers to be compiled to the right platform.

I can add the support for desktop, my initial thoughts:

  • Add new option to `-target desktop` in `gomobile bind`, or ` -target jar`
  • Add new flag to `gobind` called `platform` which default to `android` for backward compatibility and new option `desktop`.
  • If `desktop` selected, `gomobile` will check for JAVA_HOME not android SDK.
  • If `desktop` selected, it will check for `GOOS` to compile the current version of the JAR and shared library, and check if the JNI header exist in JAVA_HOME.
  • Create new file `SeqDesktop.java` which doesn't include Android Context `setContext`, or generate `Seq.java` on the fly like other .support files.
  • Create new seq_desktop.{c,go} with the appropriate headers (e.g. stdio.h instead of log.h) and include the correct flags CFLAGS, LDFLAGS per desktop platform based on `GOOS`.
  • Change all auto-generated files to match the correct platform.

Personally I want to use Go with the Kotlin Desktop Compose.

I want to ask before I start, are any of it interesting to the "x/mobile" team or not?

K

zh

unread,
Jul 22, 2025, 6:34:43 PMJul 22
to golang-nuts
I need this feature so that I can import jar files in a Spring Boot project, just like how Android imports aar files generated by gomobile.
Reply all
Reply to author
Forward
0 new messages