{"record":{"id":"92f11cc33df21b58","repo":"bevyengine/bevy","slug":"bevy-must-be-setup-with-the-bevy-main-macro-on","errorCode":null,"errorMessage":"Bevy must be setup with the #[bevy_main] macro on Android","messagePattern":"Bevy must be setup with the #\\[bevy_main\\] macro on Android","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_asset/src/io/android.rs","lineNumber":25,"sourceCode":"use std::path::Path;\n\n/// [`AssetReader`] implementation for Android devices, built on top of Android's [`AssetManager`].\n///\n/// Implementation details:\n///\n/// - All functions use the [`AssetManager`] to load files.\n/// - [`is_directory`](AssetReader::is_directory) tries to open the path\n/// as a normal file and treats an error as if the path is a directory.\n/// - Watching for changes is not supported. The watcher method will do nothing.\n///\n/// [AssetManager]: https://developer.android.com/reference/android/content/res/AssetManager\npub struct AndroidAssetReader;\n\nimpl AssetReader for AndroidAssetReader {\n    async fn read<'a>(&'a self, path: &'a Path) -> Result<impl Reader + 'a, AssetReaderError> {\n        let asset_manager = bevy_android::ANDROID_APP\n            .get()\n            .expect(\"Bevy must be setup with the #[bevy_main] macro on Android\")\n            .asset_manager();\n        let mut opened_asset = asset_manager\n            .open(&CString::new(path.to_str().unwrap()).unwrap())\n            .ok_or(AssetReaderError::NotFound(path.to_path_buf()))?;\n        let bytes = opened_asset.buffer()?;\n        let reader = VecReader::new(bytes.to_vec());\n        Ok(reader)\n    }\n\n    async fn read_meta<'a>(&'a self, path: &'a Path) -> Result<impl Reader + 'a, AssetReaderError> {\n        let meta_path = get_meta_path(path);\n        let asset_manager = bevy_android::ANDROID_APP\n            .get()\n            .expect(\"Bevy must be setup with the #[bevy_main] macro on Android\")\n            .asset_manager();\n        let mut opened_asset = asset_manager\n            .open(&CString::new(meta_path.to_str().unwrap()).unwrap())\n            .ok_or(AssetReaderError::NotFound(meta_path))?;","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_asset/src/io/android.rs#L7-L43","documentation":"Panics on Android in the asset IO layer when the app entry point was not set up with the #[bevy_main] macro. Android asset loading requires the Bevy android entry shim to initialize the AndroidApp/AssetManager state; without it there is no asset manager to read from.","triggerScenarios":"Thrown at crates/bevy_asset/src/io/android.rs:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Declare your main function with #[bevy_main] so the android shim stores the app state","Use bevy's android build setup (bevy_android / cargo-apk or the supported xbuild flow) so the entry macro is active","Verify you are building with the correct android target and entry wiring, not plain fn main"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}