In this quick tip, we’ll see how to use the excellent Android Debug Bridge (adb) tool on the command line to list all the installed packages on our android device (non-rooted in my case) and then extract one of their APK files to our computer.
List Packages
Using the package manager (pm) we can get a list of all the installed packages within the adb shell. Note: If there are multiple devices connected to adb then you’ll need to direct the command to the device of your choice.
What's the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.
$ adb shell pm list packages ... package:org.coursera.android package:com.quizup.core package:com.airbnb.android ...
Once you have the list with you, determine the package name you want to APK of. For some reason the developers of the app might choose to call the package name something that is completed unrelated to the app name. In that case find the app on Google Play Store where the URL of the app will contain the package name.
Get the APK Path
Next, we’ll need to get the path of the desired android package using the package manager again. Let’s try with com.airbnb.android (Airbnb app) in this case:
$ adb shell pm path com.airbnb.android package:/data/app/com.airbnb.android-1.apk
The output is the path of the APK file on the device’s filesystem.
Pull the APK
Finally, we’ll need to pull the APK file from the Android device (or emulator) to our computer (development box) using adb pull
.
$ adb pull /data/app/com.airbnb.android-1.apk 3484 KB/s (12796521 bytes in 3.586s)
Your app APK file should be lying in the current working directory then.
$ las -alh ... -rw-r--r-- 1 rishabhpugalia staff 12M Oct 22 15:37 com.airbnb.android-1.apk ...
Hope that helps!