fix(android): gate AssetPlugin file_path override to desktop only
`AssetPlugin::file_path = "../assets"` was set unconditionally to make `cargo run -p solitaire_app` find the workspace-root assets directory from inside `solitaire_app/`. On Android cargo-apk packages the same directory into the APK at `assets/`, and Bevy's AndroidAssetReader is already rooted there — prepending `../` walked the reader out of the APK assets root and every load failed silently. The cascade: CardImageSet handles were inserted but pointed at non-existent paths, so `card_sprite` saw `Some(set)` but the textures never resolved. The face-down branch then rendered with `Color::WHITE` over a missing texture — which on hardware showed as the `card_back_colour(0)` solid-red brick fallback that's *supposed* to only fire under MinimalPlugins in tests. Gates the `file_path` override behind `#[cfg(not(target_os = "android"))]` so Android picks up the default empty path. Closes P0 #3 of docs/android/PLAYABILITY_TODO.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,11 +132,20 @@ pub fn run() {
|
||||
..default()
|
||||
})
|
||||
// The `assets/` directory lives at the workspace root, but
|
||||
// Bevy resolves `AssetPlugin::file_path` relative to the
|
||||
// binary package's `CARGO_MANIFEST_DIR` (`solitaire_app/`).
|
||||
// Point one level up so `cargo run -p solitaire_app` finds
|
||||
// card faces, backs, backgrounds, and the UI font.
|
||||
// on desktop Bevy resolves `AssetPlugin::file_path` relative
|
||||
// to the binary package's `CARGO_MANIFEST_DIR`
|
||||
// (`solitaire_app/`), so `cargo run -p solitaire_app` would
|
||||
// miss the workspace-root `assets/` without a `../` prefix.
|
||||
//
|
||||
// On Android cargo-apk packages the same directory into the
|
||||
// APK at `assets/` (via `[package.metadata.android].assets`
|
||||
// in solitaire_app/Cargo.toml). Bevy's `AndroidAssetReader`
|
||||
// is already rooted there, so any `file_path` other than the
|
||||
// default makes it walk *out* of the APK's assets root and
|
||||
// all loads fail silently — which is what produced the
|
||||
// solid-red card-back fallback in the v0.22.3 screenshot.
|
||||
.set(bevy::asset::AssetPlugin {
|
||||
#[cfg(not(target_os = "android"))]
|
||||
file_path: "../assets".to_string(),
|
||||
..default()
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user