ziishaned
2/2/2018 - 2:41 PM

Get the Main Package Name of an .apk File

Get the Main Package Name of an .apk File

Simply use this command to get package name:

aapt dump badging {apk-file.apk} | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g

Getting main (launcher) activity is similar:

aapt dump badging {apk-file.apk} | grep launchable-activity: | awk '{print $2}' | sed s/name=//g | sed s/\'//g

For my personal usage, I've written a shell script called apkinfo.sh as following:

#!/bin/bash 
package=`aapt dump badging $* | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
activity=`aapt dump badging $* | grep launchable-activity: | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
echo
echo package : $package
echo activity: $activity

And use it as following:

./apkinfo.sh {path-to-apk-file.apk}