PHP code example of evozi / apk-parser-php

1. Go to this page and download the library: Download evozi/apk-parser-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

evozi / apk-parser-php example snippets




= new \ApkParser\Parser('MyApp.apk');
$manifest = $apk->getManifest();

echo $manifest->getPackageName();     // com.example.app
echo $manifest->getVersionName();     // 1.2.3
echo $manifest->getVersionCode();     // 10203
echo $manifest->getMinSdkLevel();     // 21
echo $manifest->getTargetSdkLevel();  // 34
echo $manifest->getMinSdk()->platform;    // e.g. "5.0 Lollipop"
var_dump($manifest->isDebuggable());  // false

foreach ($manifest->getPermissions() as $permission => $detail) {
    echo $permission . ': ' . $detail['description'] . PHP_EOL;

    if ($detail['flags']['danger']) {
        echo "  (dangerous permission)" . PHP_EOL;
    }
}

// Or just the raw android permission names:
foreach ($manifest->getPermissionsRaw() as $permission) {
    echo $permission . PHP_EOL; // e.g. android.permission.INTERNET
}

foreach ($manifest->getApplication()->activities as $activity) {
    echo $activity->name . ($activity->isLauncher ? ' (Launcher)' : '') . PHP_EOL;
}

foreach ($apk->getClasses() as $className) {
    echo $className . PHP_EOL; // e.g. com.example.app.MainActivity
}

// Resolve resource references from the manifest, e.g. the app label and icon
$label = $apk->getResources($manifest->getApplication()->getLabel());
echo $label[0];

$icons = $apk->getResources($manifest->getApplication()->getIcon());
foreach ($icons as $icon) {
    file_put_contents(basename($icon), stream_get_contents($apk->getStream($icon)));
}

// Resources can also be looked up by symbolic name instead of hex id —
// "string/app_name" and "@string/app_name" both work:
$appName = $apk->getResources('@string/app_name');

// Or fetch the entire resource table at once, indexed by hex resource id:
$all = $apk->getAllResources();

$apk->extractTo('/path/to/output');            // everything
$apk->extractTo('/path/to/output', $entries);  // or only specific entries

echo $manifest->getXmlString(); // decoded, human-readable AndroidManifest.xml

$apk = new \ApkParser\Parser('MyApp.apk', ['manifest_only' => true]);
bash
composer