Apk Parser

Read basic info about an application from .apk file.

View the Project on GitHub tufanbarisyildirim/php-apk-parser

Do you want to buy me a cup of coffee?

Welcome to Apk Parser Page.

This package can extract application package files in APK format used by devices running on Android OS. It can open an APK file and extract the contained manifest file to parse it and retrieve the meta-information it contains like the application name, description, device feature access permission it requires, etc.. The class can also extract the whole files contained in the APK file to a given directory.

Examples:
Extract All Files in .apk to a folder

$apk = new \ApkParser\Parser('EBHS.apk');
$extractFolder = 'extract_folder';

if(is_dir($extractFolder) || mkdir($extractFolder))
{
    $apk->extractTo($extractFolder);
}
                    
Read Basics

$apk = new \ApkParser\Parser('EBHS.apk');

$manifest = $apk->getManifest();
$permissions = $manifest->getPermissions();

echo '<pre>';
echo "Package Name      : " . $manifest->getPackageName()  . "\r\n";
echo "Version           : " . $manifest->getVersionName()  . " (" . $manifest->getVersionCode() . ")\r\n";
echo "Min Sdk Level     : " . $manifest->getMinSdkLevel()  . "\r\n";
echo "Min Sdk Platform  : " . $manifest->getMinSdk()->platform ."\r\n";

echo "------------- Permssions List -------------\r\n";

// find max length to print more pretty.
$perm_keys = array_keys($permissions);
$perm_key_lengths = array_map(function($perm){
    return strlen($perm);
},$perm_keys);
$max_length = max($perm_key_lengths);

foreach($permissions as $perm => $description)
{
    echo   str_pad($perm,$max_length + 4,' ') . "=> " . $description ." \r\n";
}
                    
Printout Manifest XML File.

$apk = new ApkParser\Parser('EBHS.apk');

header("Content-Type:text/xml;Charset=UTF-8");
echo $apk->getManifest()->getXmlString();