Skip to content

feat(cli): reconnect Android dev views to host Go builds - #1685

Merged
houko merged 1 commit into
nsgo-dev:mainfrom
houko:feat/android-host-dev-661
Nov 23, 2026
Merged

houko merged 1 commit into
nsgo-dev:mainfrom
houko:feat/android-host-dev-661

Conversation

@houko

@houko houko commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add nsgo dev -target android -android-host for UI development. A debuggable Android runtime accepts the host Go process through an authenticated adb forward.
  • Reconnect after a Go edit in the same Activity. Reinstall after packaged resources, launcher icons, precompiled Android classes, or release configuration change.
  • Keep the Android gamepad bridge available in host mode. Report the volume that contains the development machine's DataDir when a host-mode app calls Scope.DiskSpace.
  • Preserve the regular on-device build and share its precompiled-class packaging with the development APK.

Refs #661.

Verification

  • Rebased onto main at 091984681. The packaging helper uses the same runtime and secondary DEX inputs for host and ordinary Android builds, and the rebased renderer uses the current text protocol.
  • On a Pixel 3 XL running Android 12, a Go-only edit replaced the macOS host process while keeping the Android process and Activity. Both Go builds shared one APK install.
  • Updating a packaged resource, the launcher icon, the precompiled class archive and nsgo.yaml each caused one APK reinstall and Activity restart. Scope.DiskSpace reported valid host volume values on each launch, and shutdown removed the session's adb forward.
  • Built and launched the ordinary Android arm64 APK on the Pixel. It ran Go on Android and carried the runtime DEX, secondary DEX and native Go executable. The packaged manifest and assets kept the ordinary release configuration.
  • Rebuilt the Java runtime from source. The CLI check, the Android packaging and fingerprint tests, and TestHostDiskSpace passed. Both Android architectures passed the scoped check, and macOS arm64, Linux x64 and Windows x64 passed the host-development-tag checks.
  • The iOS simulator path landed in feat(cli): replace the iOS simulator dev executable on rebuild #1655. Its three executable replacement, resource signature and package input tests passed on this rebase. Android host sessions on Linux and Windows have build coverage.

The earlier device verification also checked rejection of an invalid host token. The earlier host-volume test ran natively on macOS, Linux and Windows x64.

@github-actions github-actions Bot added size/L enhancement New feature or request documentation Improvements or additions to documentation Android cli conflict Conflicts with the base branch; resolve it first labels Nov 21, 2026
@houko
houko force-pushed the feat/android-host-dev-661 branch from 9e5dbb2 to ba7b6d6 Compare November 21, 2026 17:34
@github-actions github-actions Bot added ci conflict Conflicts with the base branch; resolve it first and removed conflict Conflicts with the base branch; resolve it first labels Nov 21, 2026
@houko
houko force-pushed the feat/android-host-dev-661 branch from ba7b6d6 to bc4afe9 Compare November 21, 2026 18:44
@houko
houko force-pushed the feat/android-host-dev-661 branch from bc4afe9 to 3b87287 Compare November 21, 2026 22:47
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 21, 2026
@houko
houko force-pushed the feat/android-host-dev-661 branch from 3b87287 to d604ec4 Compare November 22, 2026 05:00
@houko

houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. Rebased onto main, moved the changelog bullet into changelog.d/android-host-dev.md, and checked the host session lifecycle (APK reinstall fingerprint, adb forward cleanup, token and peer-UID check, reconnect into the same Activity) and the build-tag split. Pushed bf91048: the rebased branch failed TestAndroidPipeRejectsCorruptFrames/TestAndroidProcessReportsExit (the reader only started when input was set, and the JVM stubs lacked LocalSocket/AndroidHostDev) and TestCheckWorkflowVetsEveryTargetOnce (the new tagged vet step counted as a duplicate); both now pass on Linux with JDK 21.

@houko
houko enabled auto-merge November 22, 2026 05:28
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 22, 2026
@houko
houko force-pushed the feat/android-host-dev-661 branch from bf91048 to 7b785d6 Compare November 22, 2026 08:15
@houko

houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main 3f707fd. Resolved two conflicts: writeAndroidPackage keeps main's new CrashReportBuild beside the host Debuggable flag, and NsgoView.start takes main's move of watchNetwork() ahead of attachRunningEngine() for both the process and host-socket paths. Host-tag vet for darwin/linux/windows, the cmd/nsgo Android/workflow tests and internal/platform/android with JDK 21 pass on Linux.

@houko
houko added this pull request to the merge queue Nov 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 22, 2026
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 22, 2026
@houko
houko force-pushed the feat/android-host-dev-661 branch from 7b785d6 to 7916aa3 Compare November 22, 2026 10:48
@houko
houko enabled auto-merge November 22, 2026 10:48
@houko

houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main after #1301 and pushed 7916aa3: keycodes.go from #1301 was android-only, so the host development vet step failed in the merge queue with s.physicalKey undefined; it now also builds with nsgoandroidhost. Host-tag vet for darwin/linux/windows, android vet, the cmd/nsgo Android/workflow tests and internal/platform/android with JDK 21 pass on Linux.

`nsgo dev -android-host` runs the app's Go side on this machine and shows it on the Android device over adb: the APK carries a host config asset, NsgoEngine connects to the host through a LocalSocket instead of starting libnsgo.so, and the view reconnects into the same Activity when the host rebuilds. Host builds compile the Android backend with the nsgoandroidhost tag, so every file the host build needs is tagged `android || nsgoandroidhost` (main's newer audio, assets, discovery, geometry, GPU, keyboard and automation files included; the `_android.go` audio output and GPU files are renamed so the tag applies), with disk space and streams split into device and host files. CI vets the host build for macOS, Linux and Windows.
@houko
houko force-pushed the feat/android-host-dev-661 branch from 7916aa3 to 4f28516 Compare November 23, 2026 02:32
@houko

houko commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Reworked. Squashed the six commits and rebased them onto main, keeping main's newer behaviour:

  • cmd/nsgo: androidRuntimeFiles now also prepares main's widget runtime, so the host APK path gets it too. Debuggable is androidDebuggable(p) || hostConfig != "" next to main's Launch, and the -android-host flag sits beside main's new -host bind address in devFlags/devOptions.
  • Build tags: the internal/backend run/view files combine main's !nsgotui with !nsgoandroidhost. view_other.go is !nsgotui && (nsgoandroidhost || ...). Main's newer Android files that the host build needs are tagged android || nsgoandroidhost: assets, assetpacks, audio, discovery, dev_geometry, keyboard (from feat(platform): deliver mobile hardware key callbacks #1974), automation/automation_off and testsurface. The _android.go audio output and GPU files are renamed to _runtime.go so the tag applies. authsession.go stays untagged as on main, and permissions.go stays deleted as on main. TestAutomationProtocolMatchesJava accepts the host form of the automation tags.
  • Java: NsgoEngine.destroy releases both main's live-action token and the host socket. NsgoView keeps main's releaseAllBackdrops, now inside the PR's destroyNodes, so the host reconnect releases them as well.

Verified: GOFLAGS=-tags=nsgodev,nsgoandroidhost nsgo check passes for linux_x64, windows_x64 (Linux) and macos_arm64 (macOS), including the automation hosts. go vet ./..., nsgo check -target android, NSGO_REQUIRE_JDK=1 go test ./internal/platform/android/... and the Android/host/workflow/dev tests in cmd/nsgo pass, and a full javac of the runtime succeeds.

@houko
houko merged commit f3a41cd into nsgo-dev:main Nov 23, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android ci cli documentation Improvements or additions to documentation enhancement New feature or request size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant