apkInspector

raw JSON →
1.3.6 verified Thu May 14 auth: no python

apkInspector is a Python library and CLI tool designed to provide detailed insights into the ZIP structure of APK files. It offers the capability to extract content and decode the AndroidManifest.xml file, notably without relying on external libraries for ZIP parsing. Currently at version 1.3.6, it maintains an active development cycle with frequent bug fix releases.

pip install apkinspector
error ModuleNotFoundError: No module named 'apkinspector'
cause This error occurs when the 'apkinspector' module is not installed in your Python environment.
fix
Install the 'apkinspector' module using pip: 'pip install apkinspector'.
error ImportError: cannot import name 'ApkInspector' from 'apkinspector'
cause This error occurs when attempting to import 'ApkInspector' directly, which is not the correct import path.
fix
Use the correct import statement: 'from apkinspector import apkInspector'.
error AttributeError: module 'apkinspector' has no attribute 'analyze_apk'
cause This error occurs when trying to call a non-existent function 'analyze_apk' from the 'apkinspector' module.
fix
Refer to the official documentation to use the correct functions provided by 'apkinspector'.
error TypeError: 'NoneType' object is not iterable
cause This error occurs when a function in 'apkinspector' returns None, and the code attempts to iterate over it.
fix
Ensure that the function is called with the correct parameters and that the APK file is valid.
error ValueError: Invalid APK file
cause This error occurs when 'apkinspector' is provided with a file that is not a valid APK.
fix
Verify that the file is a valid APK and not corrupted.
gotcha When parsing highly obfuscated or malformed APK files, the library might still encounter issues despite continuous improvements. The tool aims to process such files, but edge cases can lead to parsing errors or incomplete results.
fix Ensure you are using the latest version of `apkinspector` for the most robust parsing capabilities. Report specific issues with sample APKs to the GitHub repository.
gotcha APK files containing non-UTF8 characters in filenames might have been problematic in older versions, leading to parsing errors or incorrect file listings. While v1.3.0 introduced fixes, extremely rare character encodings could still cause unexpected behavior.
fix Always use the latest `apkinspector` version. If issues persist with specific filenames, consider pre-processing the APK (if safe and legal) or reporting the issue.
gotcha apkInspector is an actively developed project, meaning that while core functionalities are stable, new features or refactorings might introduce subtle changes in behavior or API additions between minor versions. Users should review release notes for updates.
fix Regularly check the GitHub releases page for new versions and their changelogs, especially before updating in production environments.
python os / libc status wheel install import disk mem side effects
3.10 alpine (musl) wheel - - 18.0M - broken
3.10 alpine (musl) - - - - - -
3.10 slim (glibc) wheel 1.5s - 19M - broken
3.10 slim (glibc) - - - - - -
3.11 alpine (musl) wheel - - 19.9M - broken
3.11 alpine (musl) - - - - - -
3.11 slim (glibc) wheel 1.5s - 20M - broken
3.11 slim (glibc) - - - - - -
3.12 alpine (musl) wheel - - 11.8M - broken
3.12 alpine (musl) - - - - - -
3.12 slim (glibc) wheel 1.4s - 12M - broken
3.12 slim (glibc) - - - - - -
3.13 alpine (musl) wheel - - 11.5M - broken
3.13 alpine (musl) - - - - - -
3.13 slim (glibc) wheel 1.5s - 12M - broken
3.13 slim (glibc) - - - - - -
3.9 alpine (musl) wheel - - 17.5M - broken
3.9 alpine (musl) - - - - - -
3.9 slim (glibc) wheel 1.7s - 18M - broken
3.9 slim (glibc) - - - - - -

This quickstart demonstrates how to initialize the library with an APK file, list its contents, and attempt to decode the `AndroidManifest.xml`. Note that for a minimal dummy APK, the manifest decoding will fail as no actual manifest is present.

import os
from apkinspector.headers import ZipEntry
from apkinspector.axml import Axml

# Assuming an APK file named 'example.apk' exists in the current directory
# For demonstration, create a dummy file if not present
if not os.path.exists('example.apk'):
    with open('example.apk', 'wb') as f:
        f.write(b'PK\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') # Empty ZIP EOCD

# Read the APK file content
with open('example.apk', 'rb') as f:
    apk_content = f.read()

# List contents of the APK
print("Listing APK entries:")
try:
    entries = ZipEntry.parse(apk_content)
    if entries:
        for entry in entries:
            print(f"  - {entry.filename}")
    else:
        print("  No entries found (this might be an empty or malformed APK).")
except Exception as e:
    print(f"Error parsing APK entries: {e}")

# Attempt to decode AndroidManifest.xml (requires a valid manifest in the APK)
# This will likely fail for a dummy APK without a real manifest
print("\nAttempting to decode AndroidManifest.xml:")
try:
    # For a real APK, 'AndroidManifest.xml' would be present
    # For this dummy example, it will likely raise an error
    manifest = Axml(apk_content, "AndroidManifest.xml")
    decoded_manifest = manifest.get_xml()
    print(decoded_manifest)
except FileNotFoundError:
    print("AndroidManifest.xml not found in the APK (as expected for a dummy APK).")
except Exception as e:
    print(f"Error decoding AndroidManifest.xml: {e}")