Skip to content

fix(ci): Resolve the Android launcher activity dynamically - #24120

Merged
MartinZikmund merged 1 commit into
feature/breakingchangesfrom
dev/mazi/ci-android-jcw
Aug 22, 2026
Merged

MartinZikmund merged 1 commit into
feature/breakingchangesfrom
dev/mazi/ci-android-jcw

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24119

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

Current behavior. build/test-scripts/android-run-skia-runtime-tests.sh launched the app with a hardcoded Java Callable Wrapper class name:

adb shell am start -n $UNO_UITEST_APP_ID/crc6448f3b0362cbf4bc9.MainActivity

That name is generated by the Android toolchain and is not a stable contract. Since the update to .NET 11 Preview 7 (#24054), the NativeAOT build emits its wrappers through the typemap as scrc64<hash> rather than crc64<hash> — different prefix and different hash — so the launch failed with:

Error: Activity class {uno.platform.samplesapp.skia.nativeaot/crc6448f3b0362cbf4bc9.MainActivity} does not exist.

The app never started, no TestResult*.xml was produced, and Tests - Android+NativeAOT Skia failed on all five attempts, on every branch build since.

Evidence, from the samplesapp-android-skia-nativeaot-logs binlog on either side of the regression:

Build Commit Generated wrapper
227595 (green) 40c4a8981 typemap/java/crc6448f3b0362cbf4bc9/MainActivity.java
228363 (red) c2831a9b45f typemap/java/scrc6415f86cac20992436/MainActivity.java

git log 40c4a8981..9582c40fd contains only the toolchain bump ("Update to .NET 11 Preview 7", "use Mono.Cecil 0.11.6") — no Uno source changes. The Mono-based Tests - Android Skia stage is unaffected because it still emits crc64….

This change resolves the launcher activity from the installed package instead of hardcoding it:

UNO_UITEST_ACTIVITY=$(adb shell cmd package resolve-activity --brief "$UNO_UITEST_APP_ID" | tail -n 1 | tr -d '\r' || true)

This is deliberately name-agnostic rather than swapping in the new constant, because the hash also moves whenever an activity's namespace or assembly changes — including when the SamplesApp heads are consolidated in #24046, which removes heads declaring namespace SamplesApp.Droid. It also fails fast with a clear message when nothing resolves, instead of waiting out the timeout and reporting the misleading did nunit crash ?.

Validation

bash -n passes. The resolution logic was exercised against a stubbed adb covering all three cases:

Toolchain output Result
…/scrc6415f86cac20992436.MainActivity (NativeAOT, current) resolved ✅
…/crc6448f3b0362cbf4bc9.MainActivity (Mono, and #24046) resolved ✅
No activity found exits 1 with an explicit error ✅

The old code sends the wrong component in the first case — which is exactly the observed CI failure. End-to-end proof needs the emulator, so the Tests - Android+NativeAOT Skia leg on this PR is the real validation.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — n/a, CI script change; validated by the stubbed-adb matrix above and by the Android+NativeAOT leg on this PR
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — n/a, no user-facing surface
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

Copilot AI lite review requested due to automatic review settings August 19, 2026 07:49
@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 39s —— View job


Review complete

  • Gather context and understand request
  • Read the changed file
  • Review for correctness, robustness, and security
  • Post inline comments for any findings
  • Post summary

Summary

Verdict: ✅ LGTM — no blocking issues

This is a clean, well-motivated fix. The root cause (JCW class-name instability between Mono crc64… and NativeAOT scrc64… toolchains) is correctly diagnosed, and the solution is name-agnostic rather than swapping one hardcoded constant for another.

Correctness: The cmd package resolve-activity --brief approach is the right tool. tail -n 1 correctly extracts the component name from the last output line; tr -d '\r' handles ADB's CR/LF output; the [[ … != */* ]] guard is an appropriate sanity check for the pkg/class format.

set -euo pipefail safety: || true is inside the command substitution $(…), so pipefail doesn't cause a premature exit when adb returns non-zero — the assignment succeeds with an empty value, and the */* check catches it cleanly.

Diagnostic fallback: When resolution fails, the script re-runs resolve-activity (without --brief or stderr suppression) before exit 1, surfacing the actual error in CI logs rather than timing out with the old misleading "did nunit crash?" message.

Quoting improvement: The original -n $UNO_UITEST_APP_ID/crc6448f3b0362cbf4bc9.MainActivity was unquoted; the replacement -n "$UNO_UITEST_ACTIVITY" is correctly quoted.

Comment quality: The block comment explaining Mono vs NativeAOT prefix differences is valuable and belongs in the code.

No findings warranting inline comments. The PR is ready to merge pending the end-to-end validation on the Tests - Android+NativeAOT Skia leg.

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

This PR fixes the Android Skia runtime-test launcher step by removing reliance on a hardcoded Java Callable Wrapper (JCW) activity name, which can change across toolchain modes (Mono vs NativeAOT) and versions. Instead, it resolves the launcher activity dynamically from the installed package before invoking am start, aligning with the instability described in issue #24119.

Changes:

  • Resolve the app’s launcher activity at runtime via adb shell cmd package resolve-activity --brief.
  • Fail fast with a clear error when no launcher activity can be resolved.
  • Use the resolved component for adb shell am start -n, replacing the previously hardcoded JCW activity.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the Android command and shell failure behavior. Dynamic resolve-activity, CR/output validation, and the quoted am start component handle Mono and NativeAOT wrapper changes without hardcoded JCW names.

@MartinZikmund

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/ci-android-jcw branch from 35e2683 to c6d8934 Compare August 20, 2026 12:42
@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 26s —— View job


Review complete

  • Gather context and understand request
  • Read the changed file
  • Review for correctness, robustness, and security
  • Post inline comments for any findings
  • Post summary

Summary

Verdict: ✅ LGTM — no blocking issues

This is a clean shell-script-only change; the AGENTS.md C#/XAML rules do not apply. Reviewing against shell correctness, robustness, and set -euo pipefail safety:

set -euo pipefail safety (line 2 + new line 137): The || true sits inside the $(…) subshell, so the pipeline-failure case resolves to an empty assignment rather than an abrupt exit — correct. The outer assignment still succeeds, and the subsequent [[ "$UNO_UITEST_ACTIVITY" != */* ]] guard catches the empty/malformed result cleanly.

resolve-activity --brief parsing: tail -n 1 correctly targets the component-name line; tr -d '\r' strips ADB's CR/LF for cross-toolchain robustness. The */* pattern check is an appropriate sanity gate for the pkg/class format, catching both "No activity found" and empty strings.

Diagnostic fallback (lines 140-142): Re-running resolve-activity without --brief or 2>/dev/null on failure surfaces the real ADB error in CI logs before exit 1 — much better than the previous silent timeout.

Quoting: The new -n "$UNO_UITEST_ACTIVITY" is correctly quoted; the original -n $UNO_UITEST_APP_ID/crc6… was not.

Comment quality: The block comment explaining Mono crc64… vs NativeAOT scrc64… instability is accurate and worth keeping in the script.

No findings warrant inline comments. The PR is ready to merge pending the Tests - Android+NativeAOT Skia end-to-end leg on this PR.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/ci-android-jcw branch from c6d8934 to 65605f8 Compare August 21, 2026 15:50
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 40s —— View job


Review complete

  • Gather context and understand request
  • Read the changed file
  • Review for correctness, robustness, and security
  • Post inline comments for any findings
  • Post summary

Summary

Verdict: ✅ LGTM — no blocking issues

This is a shell-script-only change; the C#/XAML and DependencyProperty rules from AGENTS.md do not apply. Reviewing against shell correctness, set -euo pipefail safety, and robustness:

Root cause and fix: The diagnosis is correct — the JCW class-name prefix (crc64 → scrc64) changed with the .NET 11 Preview 7 NativeAOT toolchain, and the hash is not a stable contract regardless. The fix is appropriately name-agnostic rather than swapping one hardcoded constant for another.

set -euo pipefail safety (lines 2 + 142): || true is inside the $(…) subshell, so a non-zero adb exit (or a pipefail mid-pipeline) resolves to an empty assignment rather than an abrupt script exit — correct. The [[ "$UNO_UITEST_ACTIVITY" != */* ]] guard then catches both the empty string and "No activity found" text, since neither matches the pkg/class pattern.

Parsing: cmd package resolve-activity --brief <pkg> emits a multi-line status block with the component on the final line. tail -n 1 extracts it correctly; tr -d '\r' handles ADB's CR/LF reliably.

Diagnostic fallback (lines 145-147): Re-running resolve-activity without --brief or 2>/dev/null before exit 1 surfaces the real ADB error in CI logs, replacing the previous opaque "did nunit crash?" timeout.

Quoting: New code correctly quotes both "$UNO_UITEST_APP_ID" (in the resolve call) and "$UNO_UITEST_ACTIVITY" (in am start), improving on the old unquoted component argument.

Comment quality: The block comment explaining Mono crc64… vs NativeAOT scrc64… instability is accurate and worth keeping.

Conventional Commits: fix(ci): … with imperative mood ✅.

No findings warrant inline comments. The PR is ready to merge pending the Tests - Android+NativeAOT Skia end-to-end validation on this PR's CI run.

@unodevops

Copy link
Copy Markdown
Contributor

The Android runtime-test script launched the app with a hardcoded Java
Callable Wrapper name, `crc6448f3b0362cbf4bc9.MainActivity`. That name is
generated by the Android toolchain and is not stable.

Since the update to .NET 11 Preview 7 (#24054) the NativeAOT build emits its
wrappers through the typemap as `scrc64<hash>` rather than `crc64<hash>`, and
with a different hash. Comparing the generated stubs across the last green and
first red builds of `Tests - Android+NativeAOT Skia`:

  40c4a89 (green): typemap/java/crc6448f3b0362cbf4bc9/MainActivity.java
  c2831a9 (red): typemap/java/scrc6415f86cac20992436/MainActivity.java

so `am start` failed with "Activity class {...} does not exist", the app never
ran, no TestResult XML was produced, and the stage failed on all five attempts.

Resolve the launcher activity from the installed package instead. This covers
both wrapper schemes, absorbs the hash changing when an activity's namespace or
assembly moves (as when the SamplesApp heads are consolidated), and fails fast
with a clear message instead of timing out and reporting "did nunit crash?".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xn8SQpybcpmMCwFmbCzSWt
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/ci-android-jcw branch from 65605f8 to 0589bca Compare August 22, 2026 09:51
@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 20s —— View job


Review complete

  • Gather context and understand request
  • Read the changed file
  • Review for correctness, robustness, and security
  • Post inline comments for any findings
  • Post summary

Summary

Verdict: ✅ LGTM — no blocking issues

This is a shell-script-only change. Reviewing against shell correctness, set -euo pipefail safety, and CI robustness:

Root cause and fix: The diagnosis is correct — the JCW class-name prefix (crc64… → scrc64…) changed with the .NET 11 Preview 7 NativeAOT toolchain, and the hash is also not a stable contract. The fix is appropriately name-agnostic rather than swapping one hardcoded constant for another.

set -euo pipefail safety (lines 2 + 142): || true is at the end of the full pipeline inside $(), so a non-zero adb exit or a pipefail-triggered pipeline failure resolves to an empty assignment — the outer assignment still succeeds. The [[ "$UNO_UITEST_ACTIVITY" != */* ]] guard then catches both the empty string and "No activity found" text reliably, since neither matches the pkg/class pattern.

Parsing: cmd package resolve-activity --brief <pkg> emits a multi-line status block with the component on the final line. tail -n 1 extracts it correctly; tr -d '\r' handles ADB's CR/LF output across all toolchain versions.

Diagnostic fallback (lines 145–147): Re-running resolve-activity without --brief or 2>/dev/null before exit 1 surfaces the real ADB error in CI logs rather than the previous opaque "did nunit crash?" timeout. The || true on the fallback call correctly prevents it from masking the exit 1.

Quoting: New code correctly quotes both "$UNO_UITEST_APP_ID" (in the resolve call) and "$UNO_UITEST_ACTIVITY" (in am start), improving on the old unquoted component argument.

Comment quality: The block comment explaining Mono crc64… vs NativeAOT scrc64… instability is accurate and worth keeping.

Conventional Commits: fix(ci): … with imperative mood ✅.

No findings warrant inline comments. The PR is ready to merge pending the Tests - Android+NativeAOT Skia end-to-end validation leg on this PR's CI run.

@MartinZikmund
MartinZikmund merged commit f066119 into feature/breakingchanges Aug 22, 2026
64 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/ci-android-jcw branch August 22, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants