Skip to content

feat: working Android deploy for hello-bevy-advanced#6

Open
mule wants to merge 3 commits intomainfrom
feature/android-hello-bevy-advanced
Open

feat: working Android deploy for hello-bevy-advanced#6
mule wants to merge 3 commits intomainfrom
feature/android-hello-bevy-advanced

Conversation

@mule
Copy link
Copy Markdown
Owner

@mule mule commented May 5, 2026

Summary

  • Switch Android build path from xbuild to cargo-apk; assets bundle automatically and cargo apk run --lib deploys to device.
  • Bevy 0.18 configured with android-native-activity (cargo-apk doesn't bundle the GameActivity Java glue) via explicit feature list.
  • Spotlight shader and Rust system unified on physical framebuffer pixels, fixing top-left-quadrant placement on HiDPI/mobile.
  • AndroidManifest configChanges expanded so the activity survives resize/multi-window/density events without recreation (and wgpu-surface invalidation).
  • New docs/bevy-android.md captures the full lessons learned — tooling landscape, NativeActivity rationale, coordinate spaces, manifest tuning, diagnostics, and a reference Cargo.toml — for future Bevy mobile work.

Closes #5

Test plan

  • `cargo run --manifest-path cross-platform/hello-bevy-advanced/Cargo.toml` still works on Windows desktop
  • `cargo apk run --lib` builds, installs, and launches on a Samsung Galaxy Tab S9
  • Spotlight idles at viewport center, follows touch directly under finger, returns to center on release
  • Maximize / multi-window resize on tablet does not crash
  • Text wave + particles continue to animate on Android
  • Release build (`cargo apk run --lib --release`) — not exercised this session
  • iOS — out of scope (no Mac available)

🤖 Generated with Claude Code

mule and others added 3 commits May 4, 2026 14:42
- Restructure as cdylib+rlib library with thin bin wrapper so
  bevy_winit can hook android_main on Android targets.
- Annotate the entry point with #[bevy_main].
- cfg-gate the AssetPlugin file_path override; on Android, Bevy''s
  default AAssetManager-backed loader pulls assets from the APK.
- cfg-gate config::load_config: Android embeds config.ron via
  include_str!, desktop keeps std::fs for edit-and-restart iteration.
- Replace track_mouse with track_pointer: reads Touches first,
  falls back to cursor, idles at world origin (viewport center)
  when neither is active.
- Rename the bin target to avoid a Windows PDB output-filename
  collision with the lib (hyphen/underscore normalization).

Refs #5

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- README: add Android section covering xbuild toolchain prereqs,
  build/deploy commands, and Android-specific behavior in the
  crate (cfg-gated config loading, AAssetManager, touch input,
  cdylib/bin naming). Add hello-bevy-advanced to the projects
  table and a small desktop-builds section.
- CLAUDE.md: cross-link to the Android section and document the
  cdylib+rlib entry-point pattern as an Architecture bullet.

Refs #5

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces xbuild with cargo-apk: assets bundle automatically, signing
works out of the box, and `cargo apk run --lib` is the deploy command.

Activity backend is NativeActivity because cargo-apk doesn't bundle
the GameActivity Java glue. Bevy's default android-game-activity is
swapped for android-native-activity via an explicit feature list — the
verbose form is required because Bevy's `ui` feature transitively
re-enables default_platform, which would re-enable android-game-activity.

Spotlight shader and uniforms switched to physical framebuffer pixels
to match WGSL's frag_pos coordinate space, with radius and inputs
scaled by window.scale_factor() so the effect feels consistent across
DPIs. Fixes the top-left-quadrant placement bug on HiDPI/mobile.

configChanges expanded to cover screenSize/density/uiMode/etc. so the
activity isn't recreated (and the wgpu surface invalidated) on
resize/multi-window/dpi events.

cursor_position() is cfg-gated out on Android — winit returns a stale
Some(Vec2::ZERO) on systems without a cursor, which would lock the
spotlight at the top-left.

docs/bevy-android.md captures the lessons learned: tooling landscape,
activity-backend constraint, coordinate-space gotcha, feature-list
workaround, configChanges rationale, diagnostic toolkit, and a
reference Cargo.toml for future Bevy mobile projects.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mule mule linked an issue May 5, 2026 that may be closed by this pull request
12 tasks
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.

Run hello-bevy-advanced on Android via xbuild (Galaxy Tab S9)

1 participant