{"record":{"id":"e0a360f891d78938","repo":"MuntashirAkon/AppManager","slug":"not-found-at","errorCode":null,"errorMessage":" not found at ","messagePattern":" not found at ","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java","lineNumber":322,"sourceCode":"                BitmapRandomizer.randomizePixel(bitmap);\n                bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);\n            }\n        } catch (IOException e) {\n            Log.w(TAG, \"Could not back up icon.\");\n        }\n    }\n\n    private void backupApkFiles() throws BackupException {\n        Path dataAppPath = OsEnvironment.getDataAppDirectory();\n        final String sourceBackupFilePrefix = BackupUtils.getSourceFilePrefix(getExt(mMetadata.info.tarType));\n        Path sourceDir = Paths.get(PackageUtils.getSourceDir(mApplicationInfo));\n        if (dataAppPath.equals(sourceDir)) {\n            // APK located inside /data/app directory\n            // Backup only the apk file (no split apk support for this type of apk)\n            try {\n                sourceDir = sourceDir.findFile(mMetadata.metadata.apkName);\n            } catch (FileNotFoundException e) {\n                throw new BackupException(mMetadata.metadata.apkName + \" not found at \" + sourceDir);\n            }\n        }\n        Path[] sourceFiles;\n        try {\n            sourceFiles = TarUtils.create(mMetadata.info.tarType, sourceDir, mBackupItem.getUnencryptedBackupPath(), sourceBackupFilePrefix,\n                    /* language=regexp */ new String[]{\".*\\\\.apk\"}, null, null, false).toArray(new Path[0]);\n        } catch (Throwable th) {\n            throw new BackupException(\"APK files backup is requested but no source directory has been backed up.\", th);\n        }\n        try {\n            sourceFiles = mBackupItem.encrypt(sourceFiles);\n        } catch (IOException e) {\n            throw new BackupException(\"Failed to encrypt \" + Arrays.toString(sourceFiles), e);\n        }\n        for (Path file : sourceFiles) {\n            mChecksum.add(file.getName(), DigestUtils.getHexDigest(mMetadata.info.checksumAlgo, file));\n        }\n    }","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java#L304-L340","documentation":"When the APK's sourceDir points inside /data/app, backupApkFiles() expects the base APK named by metadata.apkName to exist directly under that path; FileNotFoundException from Path.findFile() is wrapped in this BackupException with the APK name and searched directory in the message. The backup cannot proceed because the base APK to archive is missing.","triggerScenarios":"mMetadata.metadata.apkName no longer matches the on-disk APK filename in the /data/app directory — typically because the app was updated/reinstalled after the metadata was created, so the versioned apk filename changed.","commonSituations":"Restoring/redoing a backup created before an app update; apps moved between storage volumes changing their /data/app path; stale cached metadata.","solutions":["Refresh metadata for the app (re-read PackageInfo/applicationInfo.sourceDir) so apkName matches the current installation.","Update the app and back up again instead of reusing old metadata.","Verify the sourceDir actually exists and the app is still installed.","If the app is a split/featured APK, ensure the metadata apkName points at the base APK."],"exampleFix":"// before\nmMetadata.metadata.apkName = oldPackageInfo.applicationInfo.sourceDir; // stale name\n// after\nPackageInfo pi = pm.getPackageInfo(pkg, GET_METADATA);\nmMetadata.metadata.apkName = new File(pi.applicationInfo.sourceDir).getName();","handlingStrategy":"validation","validationCode":"String currentApk = new File(pm.getPackageInfo(pkg, 0).applicationInfo.sourceDir).getName();\nif (!currentApk.equals(metadata.apkName)) { refreshMetadata(); }","typeGuard":"boolean apkNameMatches(BackupMetadata meta, PackageManager pm) {\n    try {\n        String src = pm.getPackageInfo(meta.packageName, 0).applicationInfo.sourceDir;\n        return src != null && new File(src).getName().equals(meta.apkName);\n    } catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    backupOp.runBackup(progress);\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"not found at\")) { refreshMetadataAndRetry(); }\n}","preventionTips":["Refresh metadata after every app update before re-backup.","Compare metadata.apkName against the live sourceDir before backup.","Handle apps that moved between internal/external storage.","Recreate rather than reuse backups made before reinstalls."],"tags":["android","backup","apk","file-not-found"],"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-14T16:17:12.679Z"}