Android App Package Name — 5 Ways of Retrieval
When we conduct mobile software testing, we often need some metadata about the app under test (AUT). In the Android world, a Package Name is a crucial piece of information we use in either manual or automated testing.
So let’s explore the five ways to retrieve the package name of an Android application:
AAPT utility
ADB shell Package Manager
ADB shell dumpsys
APK Analyzer
Apk Info App
Alternative 1 — Use aapt
util
With access to the app source code, the package name can be found in the AndroidManifest.xml. If only the compiled .apk file is available, mobile testers can use the Android Asset Packaging Tool (aapt) to get the package name of the app.
AAPT is located in the build-tools folder of the installed Android SDK version.
The path to aapt may look as follows /Users/lana/Android/sdk/build-tools/33.0.1.
The following command reads out the package name from the .apk file:
% ./aapt d badging ~/TheApp.apk | grep 'pack'
package: name='com.appiumpro.the_app' versionCode='2003' versionName='2.0' platformBuildVersionName='11' platformBuildVersionCode='30' compileSdkVersion='30' compileSdkVersionCodename='11'
Alternative 2 — Use adb shell pm
util
adb shell pm list packages
- returns a list of packages installed on the deviceadb shell pm list packages -f <app_name>
- returns the package for the specific appadb shell pm list packages -3
- returns 3rd-party packages that were installed from the Play Store or as an .apk (not pre-installed/pre-loaded by OEMs)
Alternative 3 — Use adb shell dumpsys
util
First, start the app to ensure that it’s running on the foreground, then execute this command:
% adb shell dumpsys window windows | grep 'mCurrentFocus'
mCurrentFocus=Window{2c0df8a u0
com.my_app.standalone.test2/com.the_app.standalone.features.auth.AuthActivity}
Alternative 4 — Use apkanalyzer
util
Run the following command to retrieve the package name with APK Analyzer:
% apkanalyzer -h manifest application-id ./ApiDemos.apk
io.appium.android.apis
Alternative 5 — Download the Apk Info app from the Play Store. Use it to view the AUT’s package and activity names.
These are all the ways I discovered how to retrieve the Package Name of an Android application. Let me know if you know any others.
I welcome any comments and contributions to the subject. Connect with me on LinkedIn, X , GitHub, or Insta.