Python wrapper for aapt • ApkFile, XapkFile, ApkmFile
Project description
⛏️ apkfile • Python library for handling APK, APKM, XAPK, and APKS files
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)
How this library works?
This library uses aapt
to extract information from the .APK
file, and then parses the output to get the information.
- For the zip files (
.APKM
,.XAPK
, and.APKS
), the basic information (package_name
,version_name
,version_code
, etc.) is derived from the .json file, and the rest of the information is extracted when it requested (lazy evaluation). - The library also provide ways to install the files (and check compatibility;
min_sdk_version
,abis
andlangs
) using adb. Just connect your device/s and run theinstall
method. (you can use theinstall_apks
function independently).
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".
- You can manually provide a path to aapt:
ApkFile(..., aapt_path='/path/to/aapt')
.
Install adb
if you want to use the install
method, you need to install adb
.
- You can manually provide a path to adb:
ApkFile(...).install(adb_path='/path/to/adb')
.
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
Built Distribution
File details
Details for the file apkfile-0.1.7.tar.gz
.
File metadata
- Download URL: apkfile-0.1.7.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9d2bcc179eea27485685a1c9c5ac473f53518adfa7750a8c129a4095ee1ff3fb
|
|
MD5 |
85363227adb0f57f175faf62ee7399cf
|
|
BLAKE2b-256 |
7fd6a3b951d2670d93a67a66a26a11e86d29082eb6b1d300a5116ebc35ec28f4
|
File details
Details for the file apkfile-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: apkfile-0.1.7-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
bc7273e86f8a0b4c9dadf8b07d3ea9649f73216430b2d0c7f292c7ed56a3db21
|
|
MD5 |
3200658ba838dc956ce882e2638fed7a
|
|
BLAKE2b-256 |
6609f3af6707d2a54fbebc250c6cbf4fc2d776fb3b9b5ee9b9ad14acca9d9cc3
|