{"record":{"id":"569efd00f6720588","repo":"microg/GmsCore","slug":"fileprovider-creation-failed","errorCode":null,"errorMessage":"FileProvider creation failed","messagePattern":"FileProvider creation failed","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"play-services-core/src/main/java/org/microg/gms/settings/GmsFileProvider.kt","lineNumber":51,"sourceCode":"\n    override fun onCreate(): Boolean {\n        return true\n    }\n\n    override fun getType(uri: Uri): String? {\n        if (initializationFailed) {\n            return null\n        }\n        return super.getType(uri)\n    }\n\n    override fun openFile(\n        uri: Uri, mode: String, signal: CancellationSignal?\n    ): ParcelFileDescriptor? {\n        if (!initializationFailed) {\n            return super.openFile(uri, mode, signal)\n        }\n        throw FileNotFoundException(\"FileProvider creation failed\")\n    }\n\n    override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {\n        if (initializationFailed) {\n            return 0\n        }\n        return super.delete(uri, selection, selectionArgs)\n    }\n\n    override fun query(\n        uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?\n    ): Cursor {\n        if (initializationFailed) {\n            return MatrixCursor(emptyProjection)\n        }\n        return super.query(uri, projection, selection, selectionArgs, sortOrder)\n    }\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-core/src/main/java/org/microg/gms/settings/GmsFileProvider.kt#L33-L69","documentation":"GmsFileProvider overrides openFile and deliberately throws FileNotFoundException when the provider's initialization previously failed (initializationFailed flag). This converts a broken provider startup into a standard file-not-found for callers of ContentResolver.open* on a content:// URI.","triggerScenarios":"Calling openFile (via ContentResolver.openInputStream/openOutputStream/openFileDescriptor) on a GmsFileProvider content URI after the provider failed to initialize, e.g. because its underlying files/cache directory was unavailable at startup.","commonSituations":"Device storage issues or a corrupted provider state causing ContentProvider.onCreate to fail, then any later file access attempt surfaces this exception instead of a real descriptor.","solutions":["Check device storage and the provider's declared cache/files directories; clear the microG app data to let the provider re-initialize","Restart the microG process so onCreate runs again successfully","Investigate why initializationFailed was set (look at provider startup logs) before retrying","Handle FileNotFoundException from ContentResolver.open* gracefully and retry after fixing underlying storage issues"],"exampleFix":"// before\nval fd = contentResolver.openFileDescriptor(uri, \"r\")!!\n// after\nval fd = try { contentResolver.openFileDescriptor(uri, \"r\") } catch (e: FileNotFoundException) { null }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    contentResolver.openFileDescriptor(uri, \"r\")?.use { ... }\n} catch (e: FileNotFoundException) {\n    Log.w(TAG, \"GmsFileProvider unavailable\", e)\n}","preventionTips":["Ensure device storage is healthy so provider onCreate succeeds","Clear microG data if the provider entered a failed-initialized state","Handle FileNotFoundException from all content:// file accesses"],"tags":["android","content-provider","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}