feat: working Android deploy for hello-bevy-advanced#6
Open
Conversation
- 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>
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cargo apk run --libdeploys to device.android-native-activity(cargo-apk doesn't bundle the GameActivity Java glue) via explicit feature list.configChangesexpanded so the activity survives resize/multi-window/density events without recreation (and wgpu-surface invalidation).docs/bevy-android.mdcaptures 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
🤖 Generated with Claude Code