Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.019s · 19.2MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.4s · import 0.017s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AndroidBackup
✓ from android_backup.android_backup import AndroidBackup
✗ import android_backup
The primary class 'AndroidBackup' is nested within the 'android_backup' module itself, not directly at the top level of the package.
This quickstart demonstrates how to import and initialize the `AndroidBackup` class. Note that this library *requires Python 2.7* and external tools (`adb` and `java`) to be installed and accessible in your system's PATH for full functionality (unpacking/repacking).
# This code requires Python 2.7
import os
from android_backup.android_backup import AndroidBackup
# Create a dummy backup file for demonstration
# In a real scenario, 'backup.ab' would be an actual Android backup file
with open('dummy_backup.ab', 'w') as f:
f.write('Android Backup\n1\n0.2\nNONE\n') # Minimal header for demo
# Ensure adb and Java are in PATH for actual operations
# This example will likely fail without a valid .ab file and external tools
try:
print("Attempting to initialize AndroidBackup (requires Python 2.7, adb, and Java)")
backup = AndroidBackup(filename="dummy_backup.ab")
print("Backup object created.")
# Uncomment the following lines to actually unpack/repack if you have
# a valid backup file and external tools setup:
# backup.unpack(output_path="./unpacked_data")
# print("Backup unpacked to ./unpacked_data")
# backup.repack(input_path="./unpacked_data", output_filename="repacked_backup.ab")
# print("Backup repacked to repacked_backup.ab")
except Exception as e:
print("Could not process backup (expected if external tools are missing or .ab is invalid):", e)
finally:
if os.path.exists('dummy_backup.ab'):
os.remove('dummy_backup.ab')
Debug
Known issues
breakingThe `android-backup` library is *exclusively compatible with Python 2.7*. It explicitly does not support Python 3.x, and attempting to run it in a Python 3 environment will result in syntax errors or unexpected behavior.fixEnsure you are running the library within a Python 2.7 environment (e.g., using `virtualenv`, `conda`, or directly invoking `python2` if available).
affects: All versions (v0.2.0 and prior)
gotchaThis library relies on external tools: `Android Debug Bridge (adb)` from the Android SDK Platform-Tools and a `Java Development Kit (JDK)`. These tools must be installed and their executables must be available in your system's PATH.fixInstall the Android SDK Platform-Tools and a JDK, then add their respective `bin` directories to your system's PATH environment variable.
affects: All versions
gotchaThe library explicitly states support for Android backup format version 0.2. Backups created with older or newer Android versions might not be compatible or could lead to unexpected issues.fixVerify the backup file's format version. If it's not v0.2, consider using other tools or alternative methods for unpacking/repacking.
affects: All versions
Errors
Common errors & fixes
SyntaxError: Missing parentheses in call to 'print'
Attempting to run Python 2.x code (like `print 'hello'`) in a Python 3 interpreter.
fixYou are using `android-backup` in a Python 3 environment. This library is Python 2.7 only. Activate or create a Python 2.7 environment and run your script there.
FileNotFoundError: [Errno 2] No such file or directory: 'adb'
The `adb` command-line tool (Android Debug Bridge) is not installed or not found in your system's PATH.
fixInstall the Android SDK Platform-Tools package, which contains `adb`. Ensure the directory containing `adb` (e.g., `platform-tools`) is added to your system's PATH environment variable.
JavaException: Class not found: com/android/vts/proto/ComponentSpecification
Java or related tools are not correctly set up, or the Android backup tools' Java dependencies are not met.
fixEnsure a Java Development Kit (JDK) is installed and configured correctly. Verify that `java` is in your PATH and that the library can access necessary Java components for processing Android backup files.
Upgrade
Version history
0.2.0latest on PyPI · released Jun 6, 2018
Audit
Dependencies
No dependency data recorded yet.