{"record":{"id":"4a29c8b65e9acd86","repo":"MuntashirAkon/AppManager","slug":"no-fallback-file-found-for-statepersistfile","errorCode":null,"errorMessage":"No fallback file found for: ${statePersistFile}","messagePattern":"No fallback file found for: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"critical","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/ssaid/SettingsStateV26.java","lineNumber":848,"sourceCode":"        } catch (IOException | RemoteException fnfe) {\n            Log.w(LOG_TAG, \"No settings state %s\", mStatePersistFile);\n            logSettingsDirectoryInformation(mStatePersistFile);\n            addHistoricalOperationLocked(HISTORICAL_OPERATION_INITIALIZE, null);\n            return;\n        }\n        if (parseStateFromXmlStreamLocked(in)) {\n            return;\n        }\n\n        // Settings file exists but is corrupted. Retry with the fallback file\n        Path statePersistFallbackFile = Paths.get(mStatePersistFile.getFilePath() + FALLBACK_FILE_SUFFIX);\n        Log.i(LOG_TAG, \"Failed parsing settings file: %s, retrying with fallback file: %s\", mStatePersistFile,\n                statePersistFallbackFile);\n        try {\n            in = new AtomicExtendedFile(statePersistFallbackFile.getFile()).openRead();\n        } catch (IOException | RemoteException fnfe) {\n            final String message = \"No fallback file found for: \" + mStatePersistFile;\n            throw new IllegalStateException(message, fnfe);\n        }\n        if (parseStateFromXmlStreamLocked(in)) {\n            // Parsed state from fallback file. Restore original file with fallback file\n            try {\n                IoUtils.copy(statePersistFallbackFile, mStatePersistFile);\n            } catch (IOException ignored) {\n                // Failed to copy, but it's okay because we already parsed states from fallback file\n            }\n        } else {\n            final String message = \"Failed parsing settings file: \" + mStatePersistFile;\n            throw new IllegalStateException(message);\n        }\n    }\n\n    @GuardedBy(\"mLock\")\n    private boolean parseStateFromXmlStreamLocked(InputStream in) {\n        try {\n            TypedXmlPullParser parser = Xml.resolvePullParser(in);","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/ssaid/SettingsStateV26.java#L830-L866","documentation":"IllegalStateException thrown when the primary settings XML file failed to parse and the fallback file also cannot be opened for reading (FileNotFoundException/IOException/RemoteException on the fallback path). The state manager needs at least one readable copy of the state; with neither available it aborts rather than returning empty state, which would silently wipe settings.","triggerScenarios":"Parsing mStatePersistFile fails, code retries with statePersistFallbackFile, and AtomicExtendedFile(fallback).openRead() throws — e.g. the fallback file does not exist, was deleted, or resides on storage that is unreadable (permissions/mount issues).","commonSituations":"Corrupted primary settings_ssaid.xml combined with a missing or wiped fallback after an interrupted first write; root-based modification deleting both files; encrypted-storage/SELinux contexts blocking read of /system/users/0 files.","solutions":["Restore a valid settings_ssaid.xml from backup to the user system directory","Check that both the primary and fallback files exist and are readable (root/adb shell ls -l) and fix permissions/context","Catch IllegalStateException and rebuild the settings state from defaults rather than crashing","Re-trigger state creation by letting the framework regenerate the file (e.g. clear the relevant package data / reboot)"],"exampleFix":"// before\nin = new AtomicExtendedFile(statePersistFallbackFile.getFile()).openRead();\n// after\nFile f = statePersistFallbackFile.getFile();\nif (!f.exists() || !f.canRead()) {\n    Log.w(LOG_TAG, \"Fallback missing; initializing empty state for \" + mStatePersistFile);\n    return; // or initializeDefaultsLocked()\n}\nin = new AtomicExtendedFile(f).openRead();","handlingStrategy":"fallback","validationCode":"File primary = mStatePersistFile.getFile();\nFile fallback = statePersistFallbackFile.getFile();\nif (!primary.canRead() && !fallback.canRead()) {\n    Log.w(TAG, \"No settings state available; initializing defaults\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    state = loadSettingsState();\n} catch (IllegalStateException e) {\n    Log.e(TAG, \"No readable settings file or fallback\", e);\n    state = initializeDefaultState();\n}","preventionTips":["Maintain an external backup of settings_ssaid.xml before modifications","Never delete both primary and fallback copies manually","Perform atomic writes only through the provided AtomicExtendedFile APIs","Check storage mount/permission state before touching /data/system files"],"tags":["android","file-io","corruption","ssaid"],"backgroundTag":"file-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}