Skip to content

android: Cgo removal is blocked by the gomobile/x-mobile JVM bridge (tracking) #126

Description

@changkun

Tracking the Android conclusion from the merged design spec specs/mobile-remove-cgo.md (#123): Android cannot drop the Cgo / C-toolchain dependency under the current gomobile model. Filing so the rationale is discoverable and the investigation isn't repeated.

Why it's blocked

  1. The backend needs golang.org/x/mobile/app.RunOnJVMinternal/mobileinit.RunOnJVM, implemented with C.lockJNI/C.unlockJNI/C.checkExceptionCgo, pulled in transitively before our own clipboard_android.c.
  2. gomobile Android apps build -buildmode=c-shared via the NDK; CGO_ENABLED=0 is not a supported flow. Empirically GOOS=android CGO_ENABLED=0 go build . fails on the x/mobile/app import.

Considered and rejected

purego-over-JNI (purego supports Android dlopen): would replace clipboard_android.c but not remove the toolchain requirement — x/mobile/app stays Cgo and the NDK c-shared build stays. Churn + unsafe risk with zero movement toward the goal.

Revisit when

The JVM/Context lifecycle (current JNIEnv + app Context) can be obtained without a Cgo x/mobile dependency. Until then: no source change; Android keeps Cgo + NDK, and clipboard_nocgo.go keeps its !android exclusion. See spec §7.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions