If you’ve been given an APK file but don’t know the ApplicationId/Package name, you can use the ‘aapt’ (Android Asset Packaging Tool) to obtain this value. What you’ll need:
- Your Android SDK install directory path
- Mac: /Users/yourusername/Library/Android/sdk
- Win: C:\Program Files\Android\SDK
- Your APK file (example here)
You’ll have to navigate beyond the SDK folder to the ‘build-tools’ and then your version number (see below) to find the ‘aapt’ tool. From that directory, you can run:
aapt dump badging <path to your apk>
This will dump the details of your app manifest, the first line of which is your package name (a.k.a. the ApplicationId in a build.gradle file).
Additionally, you can get a complete listing of the manifest by using:
aapt list -a <path to your apk>
Why Do I need the the Application ID / Package Name?
For various reasons, this identifier is important. For instance, debugging with the ADB command tools or launching an existing app requires this ID.
I have to add the “.test” suffix to the package name coming from aapt because I need to tell the Perfecto Espresso executor to run tests.