Skip to main content

Python wrapper for aapt • ApkFile, XapkFile, ApkmFile

Project description

⛏️ apkfile • Python wrapper for aapt

CodeFactor PyPI Version

apkfile is a Python library that extracts information from .APK, .APKM, .XAPK, and .APKS files using aapt. It provides additional metadata beyond what's available in the AndroidManifest.xml file, such as the abis, minSdkVersion, targetSdkVersion, and more.

Installation

Install with pip

pip3 install -U apkfile

Or, install from source:

git clone https://github.com/david-lev/apkfile.git
cd apkfile
python3 setup.py install

You also need to install aapt (see Install aapt below).

Usage

from apkfile import ApkFile, XapkFile, ApkmFile, ApksFile

# Get apk info
apk_file = ApkFile(path='/home/david/Downloads/wa.apk')
print(apk_file.package_name, apk_file.version_name, apk_file.version_code)
print(apk_file.as_dict())

# Get apkm info
apkm_file = ApkmFile('/home/david/Downloads/chrome.apkm')
for split in apkm_file.splits:
    print(split.split_name)
apkm_file.install(check=True, upgrade=True)

# Using context manager (delete the extracted files when done)
with XapkFile(path='/home/david/Downloads/telegram.xapk') as xf:
    print(xf.base.abis, x.permissions, x.langs)

# Get apks info
apks_file = ApksFile(path='/home/david/Downloads/facebook.apks')
print(apks_file.base.permissions, apks_file.md5, apks_file.sha256)

Install aapt

apkfile requires aapt to be in the PATH. In each operating system, the way to install aapt is different, if you installed Android Studio, add one of the build-tools paths to the PATH, if you are on a Debian-based Linux system (Ubuntu etc.) you can install with sudo apt install aapt, and on Windows and Mac? Just google "How to install aapt on X".

  • If you do not have access to PATH, you can manually provide a path to aapt: ApkFile(..., aapt_path='/path/to/aapt').

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apkfile-0.1.3.tar.gz (12.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page