{"record":{"id":"14667a52cb0f8ee1","repo":"DioxusLabs/dioxus","slug":"invalid-asset-manager","errorCode":null,"errorMessage":"Invalid asset manager","messagePattern":"Invalid asset manager","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/asset-resolver/src/native.rs","lineNumber":287,"sourceCode":"\n    // Query the Asset Manager\n    let asset_manager_ptr = env\n        .call_method(\n            unsafe { jni::objects::JObject::from_raw(ctx.context().cast()) },\n            \"getAssets\",\n            \"()Landroid/content/res/AssetManager;\",\n            &[],\n        )\n        .expect(\"Failed to get asset manager\")\n        .l()\n        .expect(\"Failed to get asset manager as object\");\n\n    unsafe {\n        let asset_manager =\n            ndk_sys::AAssetManager_fromJava(env.get_native_interface(), *asset_manager_ptr);\n\n        let asset_manager = ndk::asset::AssetManager::from_ptr(\n            NonNull::new(asset_manager).expect(\"Invalid asset manager\"),\n        );\n\n        let cstr = std::ffi::CString::new(normalized).unwrap();\n\n        let mut asset = asset_manager.open(&cstr)?;\n        Some(asset.buffer().unwrap().to_vec())\n    }\n}\n","sourceCodeStart":269,"sourceCodeEnd":296,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/asset-resolver/src/native.rs#L269-L296","documentation":"Android panic in to_java_load_asset: AAssetManager_fromJava returned NULL, so a native ndk AssetManager could not be constructed from the Java reference; the code expects a non-null pointer via NonNull::new.","triggerScenarios":"Passing a stale or wrong Java object to AAssetManager_fromJava: an AssetManager whose local JNI reference expired, or a manager from a different context lifetime/classloader than assumed.","commonSituations":"Caching the Java AssetManager reference across events/threads so the local reference dies; custom asset plumbing bypassing dioxus; app teardown edge cases where the manager is already destroyed.","solutions":["Let dioxus resolve assets through its own JNI path on the same thread immediately after obtaining the context","Avoid caching Java AssetManager references across events or threads","Keep the standard dioxus Android launch flow instead of custom asset manager plumbing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve assets on the thread that obtained the Android context instead of caching references","Do not store Java AssetManager references across events or threads","Prefer dioxus's own asset path over hand-rolled JNI asset plumbing"],"tags":["android","ndk","assets","null-pointer","panic","runtime"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}