From fcc7337c97fc19bdbe08b906628d0ce7923e2a3a Mon Sep 17 00:00:00 2001 From: funman300 Date: Sun, 10 May 2026 20:41:06 -0700 Subject: [PATCH] fix(android): gate AssetPlugin file_path override to desktop only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 --- solitaire_app/src/lib.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/solitaire_app/src/lib.rs b/solitaire_app/src/lib.rs index cc778c1..02e7855 100644 --- a/solitaire_app/src/lib.rs +++ b/solitaire_app/src/lib.rs @@ -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() }),