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
- The backend needs
golang.org/x/mobile/app.RunOnJVM → internal/mobileinit.RunOnJVM, implemented with C.lockJNI/C.unlockJNI/C.checkException — Cgo, pulled in transitively before our own clipboard_android.c.
- 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.
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
golang.org/x/mobile/app.RunOnJVM→internal/mobileinit.RunOnJVM, implemented withC.lockJNI/C.unlockJNI/C.checkException— Cgo, pulled in transitively before our ownclipboard_android.c.-buildmode=c-sharedvia the NDK;CGO_ENABLED=0is not a supported flow. EmpiricallyGOOS=android CGO_ENABLED=0 go build .fails on the x/mobile/app import.Considered and rejected
purego-over-JNI (purego supports Android
dlopen): would replaceclipboard_android.cbut not remove the toolchain requirement — x/mobile/app stays Cgo and the NDK c-shared build stays. Churn +unsaferisk with zero movement toward the goal.Revisit when
The JVM/
Contextlifecycle (currentJNIEnv+ appContext) can be obtained without a Cgox/mobiledependency. Until then: no source change; Android keeps Cgo + NDK, andclipboard_nocgo.gokeeps its!androidexclusion. See spec §7.