Skip to content

fix(android): unbreak build from #8754 + gate Kotlin compile on PRs#8827

Merged
myleshorton merged 1 commit into
mainfrom
fix/android-build-break-and-kotlin-gate
May 29, 2026
Merged

fix(android): unbreak build from #8754 + gate Kotlin compile on PRs#8827
myleshorton merged 1 commit into
mainfrom
fix/android-build-break-and-kotlin-gate

Conversation

@myleshorton

Copy link
Copy Markdown
Contributor

Why

main's Android app does not compile. #8754 (Android sideload auto-updates) added a bare success(status) call in MethodHandler.onMethodCall's InstallSideloadUpdate branch:

scope.launch {
    try {
        val status = AndroidSideloadInstaller.install(MainActivity.instance, update)
        withContext(Dispatchers.Main) {
            success(status)        // ← e: Unresolved reference 'success'
        }
    } ...
}

success(...) is not a helper method — every other call site is inside a result.runCatching { … } block, where the implicit receiver this is the MethodChannel.Result, so success(...) resolves to MethodChannel.Result.success() (the Flutter API). Inside this scope.launch { … withContext(Dispatchers.Main) { } } block there is no result receiver, so it doesn't resolve and the Kotlin compile fails.

Fix

One line — qualify it explicitly:

-                            success(status)
+                            result.success(status)

result.error(...) is already used in the same branch's catch, so result is in scope.

Why it shipped broken — and the gate

build-android.yml is workflow_call-only (invoked by the release flow) and never runs on PRs or pushes. PR CI is only Go CI / CodeQL, neither of which compiles app Kotlin. So this merged undetected.

This PR adds android-compile-check.yml: on PRs touching android/**, lantern-core/**, go.mod/go.sum, Makefile, or pubspec* (i.e. anything that can break Kotlin compilation, directly or via the gomobile AAR), it builds the debug APK — which compiles all app Kotlin. Debug-only, so it needs no keystore/APP_ENV secrets and skips the AAB/signing/upload. This PR's own run of the gate (it touches both Kotlin and the workflow) doubles as its validation.

Verification

Locally on this branch: fresh gomobile AAR + make android-debug✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installed on an Android 11 / API 30 emulator, connected the VPN successfully (no crash, traffic routed).

Follow-up worth considering: android-compile-check runs on macos-26 to match the known-good build-android environment; a Linux runner would be cheaper for a per-PR gate if the gomobile Android build is verified to work there.

#8754 (Android sideload auto-updates) added a bare `success(status)` call in
MethodHandler.onMethodCall's InstallSideloadUpdate branch. `success(...)` is not
a helper — it resolves to MethodChannel.Result.success() via the implicit
receiver of the surrounding `result.runCatching { }` blocks. Inside the
`scope.launch { withContext(Dispatchers.Main) { } }` block there is no `result`
receiver, so it failed to compile ("Unresolved reference 'success'"). Qualify it
as `result.success(status)`.

This shipped to main because build-android.yml is workflow_call-only and never
ran on PRs — no CI gate compiles app Kotlin. Add android-compile-check.yml: on
PRs touching Kotlin/Android (or the Go/deps feeding the gomobile AAR), build the
debug APK, which compiles all app Kotlin. Debug-only, so no signing secrets.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Kotlin compilation break in the Android MethodChannel handler introduced in #8754, and adds a PR-time CI gate to ensure Android/Kotlin compilation is exercised whenever Android- or gomobile-related changes are proposed.

Changes:

  • Qualify the MethodChannel result call in InstallSideloadUpdate to result.success(...) to restore Kotlin compilation.
  • Add a new android-compile-check GitHub Actions workflow that runs on PRs touching Android/gomobile-affecting paths and builds the debug APK (compiling all app Kotlin).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
android/app/src/main/kotlin/org/getlantern/lantern/handler/MethodHandler.kt Fixes the unresolved success(...) call by explicitly using result.success(status) inside the coroutine context.
.github/workflows/android-compile-check.yml Adds a PR-triggered debug APK build to gate Android/Kotlin compilation on relevant PR changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@myleshorton myleshorton merged commit 86d65ef into main May 29, 2026
9 of 10 checks passed
@myleshorton myleshorton deleted the fix/android-build-break-and-kotlin-gate branch May 29, 2026 21:40
myleshorton added a commit that referenced this pull request May 29, 2026
…ts (#8828)

The android-compile-check gate (added in #8827) failed at asset bundling —
'No file or variants found for asset: app.env' — because app.env is a declared
pubspec asset that only the release workflow decodes (from a secret). Kotlin and
Dart compiled fine; the build only choked at bundling. This gate is compile-only
and never runs the app, so touch an empty app.env to satisfy bundling without
needing the secret.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants