MuntashirAkon/AppManager · error · BackupException
Could not fetch package info
Error message
Could not fetch package info
What it means
Thrown by SBConverter.generateMetadata when PackageManager.getPackageArchiveInfo returns null for the cached APK. This means the APK file could not be parsed as a valid Android package (invalid zip, corrupt manifest, wrong architecture-independent header), so label/version/package name cannot be derived.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java:285
}
@SuppressLint("WrongConstant")
@NonNull
private BackupMetadataV2 generateMetadata() throws BackupException {
BackupMetadataV2 metadataV2 = new BackupMetadataV2();
mCachedApk = FileUtils.getTempPath(mPackageName, "base.apk");
try (InputStream pis = getApkFile().openInputStream()) {
try (OutputStream fos = mCachedApk.openOutputStream()) {
IoUtils.copy(pis, fos);
}
mFilesToBeDeleted.add(getApkFile());
} catch (IOException e) {
throw new BackupException("Could not cache APK file", e);
}
String filePath = Objects.requireNonNull(mCachedApk.getFilePath());
PackageInfo packageInfo = mPm.getPackageArchiveInfo(filePath, 0);
if (packageInfo == null) {
throw new BackupException("Could not fetch package info");
}
mPackageInfo = packageInfo;
Objects.requireNonNull(mPackageInfo.applicationInfo);
mPackageInfo.applicationInfo.publicSourceDir = filePath;
mPackageInfo.applicationInfo.sourceDir = filePath;
ApplicationInfo applicationInfo = mPackageInfo.applicationInfo;
if (!mPackageInfo.packageName.equals(mPackageName)) {
throw new BackupException("Package name mismatch: Expected=" + mPackageName + ", Actual=" + mPackageInfo.packageName);
}
metadataV2.label = applicationInfo.loadLabel(mPm).toString();
metadataV2.packageName = mPackageName;
metadataV2.versionName = mPackageInfo.versionName;
metadataV2.versionCode = PackageInfoCompat.getLongVersionCode(mPackageInfo);
metadataV2.isSystem = false;
metadataV2.hasRules = false;
metadataV2.backupTime = mBackupTime;View on GitHub (pinned to 0152f468fc)
Solutions
- Verify the cached APK opens as a valid zip and contains AndroidManifest.xml (try aapt dump badging).
- Re-export or re-copy the source backup to get a complete APK.
- Ensure metadata.apkName points at the real base APK, not a split or unrelated file.
- Test the same APK installs via a package installer; if it doesn't, the APK itself is corrupt.
Example fix
// before: assume parse succeeds
PackageInfo pi = pm.getPackageArchiveInfo(path, 0);
// after: validate archive before asking PM
try (ZipFile zf = new ZipFile(path)) {
if (zf.getEntry("AndroidManifest.xml") == null)
throw new IOException("not a valid APK: " + path);
}
PackageInfo pi = pm.getPackageArchiveInfo(path, 0);
if (pi == null) throw new IOException("PM could not parse APK: " + path); Defensive patterns
Strategy: validation
Validate before calling
PackageInfo pi = pm.getPackageArchiveInfo(cachedApkPath, 0);
if (pi == null) {
// APK not parseable; fail before conversion instead of mid-way
try (ZipFile zf = new ZipFile(cachedApkPath)) {
if (zf.getEntry("AndroidManifest.xml") == null)
throw new IOException("not a valid APK");
}
} Try / catch
try { converter.convert(); }
catch (BackupException e) {
if (e.getMessage().equals("Could not fetch package info")) {
// treat source APK as corrupt; re-export or reject the source
}
} Prevention
- Verify APKs with 'aapt dump badging' before conversion
- Reject truncated source archives up front
- Ensure apkName points to a real base APK, not a split or asset
- Test suspicious APKs with an installer before relying on them
When it happens
Trigger: The cached base.apk is truncated or corrupt; the file is not actually an APK (e.g., wrong file stored under apkName); getPackageArchiveInfo fails to read the compiled manifest on this Android version.
Common situations: Partially downloaded or interrupted Swift Backup exports; source archives created by modified/custom backup tools storing non-APK payloads; heavily obfuscated or broken APKs on newer Android parsing rules.
Related errors
- Package cannot be parsed.
- not found at
- APK files backup is requested but no source directory has be
- Failed to encrypt
- APK restore is requested but backup doesn't contain any sour
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/b3a09a807d9d2261.
Report an issue: GitHub.