Registry / serialization / apkutils2

apkutils2

JSON →
library1.0.0pypypi✓ verified 85d ago

apkutils2 is a Python library designed for parsing and analyzing Android Package (APK) files. It offers functionalities to extract manifest information, package details, certificate data, and other resources. This library is a complete rewrite of the original `apkutils` and is currently at version 1.0.0, with an infrequent release cadence focusing on stability.

pip install apkutils2
INSTALL
IMPORT
SIG · APKUTILS2
A
apkutils2
serializationpythonv1.0.0
Install
2.7s avg
Import
328ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.343s · 21.4MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.7s · import 0.313s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

APK
from apkutils2 import APK
from apkutils import APK
apkutils2 is a complete rewrite and has a different API and import path than the older apkutils library.

This quickstart demonstrates how to initialize the APK parser and extract basic information like package name, version, and manifest. It requires a valid APK file to be present at the specified path.

from pathlib import Path from apkutils2 import APK # IMPORTANT: Replace "path/to/your.apk" with the actual path to an Android APK file. # You must have a valid .apk file to run this example. apk_file_path = Path("path/to/your.apk") # e.g., Path("/home/user/my_app.apk") try: if not apk_file_path.exists(): raise FileNotFoundError(f"APK file not found: {apk_file_path}. " "Please update 'apk_file_path' to a valid APK file.") apk = APK(str(apk_file_path)) # The constructor expects a string path print(f"Package Name: {apk.package_name}") print(f"Version Name: {apk.version_name}") print(f"Version Code: {apk.version_code}") print(f"Min SDK Version: {apk.get_min_sdk_version()}") # To get the full manifest XML: manifest_xml = apk.get_manifest().toprettyxml() print("\nManifest (first 200 chars):") print(manifest_xml[:200] + "...") # Example of getting certificate information certs = apk.get_certs() if certs: cert = certs[0] # Get the first certificate print(f"\nCertificate Subject: {cert.get_subject()}") print(f"Certificate Issuer: {cert.get_issuer()}") else: print("\nNo certificates found.") except Exception as e: print(f"An error occurred: {e}") print("Please ensure you have a valid APK file at the specified path.")
Debug
Known issues
breakingapkutils2 is a complete rewrite and not an incremental upgrade from the original `apkutils` library. Existing code relying on `apkutils`'s API will not work with `apkutils2`.
fix
Rewrite code to use `apkutils2`'s new API and ensure imports are `from apkutils2 import APK`.
affects: All versions of apkutils2 compared to apkutils.
gotchaThe `APK()` constructor expects a valid path to an actual, readable APK file. Passing a non-existent path or a non-APK file (e.g., an empty file or a text file) will lead to `FileNotFoundError`, `zipfile.BadZipFile`, or other parsing errors.
fix
Always verify that the path provided to `APK()` points to a legitimate `.apk` file that your program has read access to.
affects: All
gotchaapkutils2 relies heavily on `androguard`, which can have complex dependencies or installation issues, particularly on certain operating systems or Python environments due to its low-level requirements.
fix
If `apkutils2` installation or execution fails, specifically investigate `androguard`'s documentation for system-level dependencies or compatibility notes, and try installing `androguard` directly first.
affects: All
Errors
Common errors & fixes
FileNotFoundError: [Errno 2] No such file or directory: 'non_existent.apk'
The APK file path provided to the `APK()` constructor does not exist on the file system.
fix
Ensure the path passed to `APK()` is correct and points to an existing `.apk` file. Use an absolute path or verify the current working directory.
zipfile.BadZipFile: File is not a zip file
The file provided to the `APK()` constructor is not a valid ZIP archive (APKs are essentially ZIP files). This usually means the file is corrupted, empty, or not actually an APK.
fix
Verify that the file at the given path is a legitimate, uncorrupted APK file. Try opening it with a standard ZIP utility if unsure.
ImportError: cannot import name 'APK' from 'apkutils'
You are attempting to import `APK` from the older `apkutils` library, but `apkutils2` is installed, or `apkutils2` is installed but you're trying to import using the old path.
fix
If you intend to use `apkutils2`, ensure your import statement is `from apkutils2 import APK`. If you need `apkutils`, install that library explicitly (`pip install apkutils`) and use its specific import paths.
Upgrade
Version history
1.0.0latest on PyPI · released Jul 31, 2019
Audit
Dependencies
protobufrequiredUsed for parsing various binary formats within APKs.
pyasn1requiredRequired for parsing ASN.1 structures, particularly in certificates.
pyasn1_modulesrequiredProvides additional ASN.1 modules for certificate parsing.
clickrequiredUsed for command-line interface utilities.
androguardrequiredCore dependency for deep APK analysis, including manifest, resources, and code analysis.
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
apkutils2 — pip install apkutils2 · libregistry