{"record":{"id":"88cf6a5e6a2c09ed","repo":"MuntashirAkon/AppManager","slug":"could-not-read-package-name","errorCode":null,"errorMessage":"Could not read package name.","messagePattern":"Could not read package name\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/TBConverter.java","lineNumber":106,"sourceCode":"     *\n     * @param propFile Location to the properties file e.g. {@code /sdcard/TitaniumBackup/package.name-YYYYMMDD-HHMMSS.properties}\n     */\n    public TBConverter(@NonNull Path propFile) {\n        mPropFile = propFile;\n        mBackupLocation = propFile.getParent();\n        mUserId = UserHandleHidden.myUserId();\n        String dirtyName = propFile.getName();\n        int idx = dirtyName.indexOf('-');\n        if (idx == -1) mPackageName = null;\n        else mPackageName = dirtyName.substring(0, idx);\n        mBackupTime = propFile.lastModified();  // TODO: Grab from the file name\n        mFilesToBeDeleted.add(propFile);\n    }\n\n    @Override\n    public void convert() throws BackupException {\n        if (mPackageName == null) {\n            throw new BackupException(\"Could not read package name.\");\n        }\n        // Source metadata\n        mSourceMetadata = readPropFile();\n        // Simulate a backup creation\n        try {\n            mBackupItem = BackupItems.createBackupItemGracefully(mUserId, \"TB\", mPackageName);\n        } catch (IOException e) {\n            throw new BackupException(\"Could not get backup files\", e);\n        }\n        boolean backupSuccess = false;\n        try {\n            try {\n                // Destination metadata\n                mDestMetadata = ConvertUtils.getV5Metadata(mSourceMetadata, mBackupItem);\n                // Destination APK will be renamed\n                mDestMetadata.metadata.apkName = \"base.apk\";\n            } catch (CryptoException e) {\n                throw new BackupException(\"Failed to get crypto \" + mDestMetadata.info.crypto, e);","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/TBConverter.java#L88-L124","documentation":"Thrown by TBConverter.convert() when mPackageName is null at conversion start. The Titanium Backup converter requires the target package name to locate the source backup folder and create the destination backup item, so a null name makes conversion impossible.","triggerScenarios":"Constructing TBConverter without supplying a package name (constructor argument missing or resolved from a folder name that could not be parsed), then calling convert(); converters invoked from code paths that don't validate the package identifier first.","commonSituations":"Titanium Backup folders whose naming convention ('com.example.app-YYYYMMDD...') doesn't match the parser's expectations, e.g., folders renamed by the user or created by non-standard tools; programmatic use passing null instead of the folder-derived name.","solutions":["Pass a non-null package name when constructing TBConverter, or ensure the source folder name follows the Titanium Backup 'packageName-date' convention so it can be parsed.","Validate the package name before calling convert(): if (packageName == null) fail early with a clear message.","Rename the Titanium Backup folder to the standard format and re-run conversion.","Check the caller (e.g., conversion UI) isn't losing the selected package name due to an intent/selection bug."],"exampleFix":"// before\nnew TBConverter(userId, null, sourceDir).convert();\n// after\nString pkg = parsePackageFromFolderName(sourceDir.getName());\nObjects.requireNonNull(pkg, \"cannot derive package from \" + sourceDir);\nnew TBConverter(userId, pkg, sourceDir).convert();","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(packageName, \"package name required for TB conversion\");\nif (!packageName.matches(\"[A-Za-z][A-Za-z0-9_]*(\\\\.[A-Za-z][A-Za-z0-9_]*)+\"))\n    throw new IllegalArgumentException(\"not a valid package name: \" + packageName);","typeGuard":null,"tryCatchPattern":"try { converter.convert(); }\ncatch (BackupException e) {\n    if (e.getMessage().equals(\"Could not read package name.\")) {\n        // folder name didn't parse; prompt user to pick the package manually\n    }\n}","preventionTips":["Keep Titanium Backup folder names in the original 'pkg-date' format","Never pass null package names to converter constructors","Parse and log the derived package name before converting","Reject malformed folder names during source scan"],"tags":["android","backup","titanium-backup","validation"],"backgroundTag":"null-argument","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"}