microg/GmsCore · error · FileNotFoundException
FileProvider creation failed
Error message
FileProvider creation failed
What it means
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.
Source
Thrown at play-services-core/src/main/java/org/microg/gms/settings/GmsFileProvider.kt:51
override fun onCreate(): Boolean {
return true
}
override fun getType(uri: Uri): String? {
if (initializationFailed) {
return null
}
return super.getType(uri)
}
override fun openFile(
uri: Uri, mode: String, signal: CancellationSignal?
): ParcelFileDescriptor? {
if (!initializationFailed) {
return super.openFile(uri, mode, signal)
}
throw FileNotFoundException("FileProvider creation failed")
}
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
if (initializationFailed) {
return 0
}
return super.delete(uri, selection, selectionArgs)
}
override fun query(
uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?
): Cursor {
if (initializationFailed) {
return MatrixCursor(emptyProjection)
}
return super.query(uri, projection, selection, selectionArgs, sortOrder)
}
}View on GitHub (pinned to 157c9d86ac)
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
Example fix
// before
val fd = contentResolver.openFileDescriptor(uri, "r")!!
// after
val fd = try { contentResolver.openFileDescriptor(uri, "r") } catch (e: FileNotFoundException) { null } Defensive patterns
Strategy: try-catch
Try / catch
try {
contentResolver.openFileDescriptor(uri, "r")?.use { ... }
} catch (e: FileNotFoundException) {
Log.w(TAG, "GmsFileProvider unavailable", e)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Access denied, missing google package permission or GET_ACCO
- Unsupported method call %s(%s).
- Unknown key: $key
- deleteAll was set to true but keys were also provided
- Element in keys cannot be null or empty
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/569efd00f6720588.
Report an issue: GitHub.