Extract an APK From Android Devices using ADB
While working on a side project I had a need to extract an APK from my Android phone. This post briefly describes the process on how to do that.
Equipment used: Samsung phone with Android 9, Laptop running Ubuntu 18.04
- adb - How do I get an apk file from an Android device? [stackoverflow.com]
- Android Studio - How to Change Android SDK Path [stackoverflow.com]
- How to Install and Use ADB, the Android Debug Utility [howtogeek.com]
Ensure Android is in Developer Mode
Each phone might be a little different in this respect, but the process is generally:
- Go to Settings
- Find 'About Phone' (or similar)
- Scroll down to view the
- Tap the build number 7 times
- Go back to Settings and you should see a
Identify where ADB is installed
I used the Jetbrains Toolbox to install Android Studio and wasn't sure where it placed the Android SDK. To find the SDK location within Android Studio:
- File -> Project Structure...
In the left-hand sidebar select
(In my case the SDK was installed to
/home/username/Android/Sdkand the ADB tool was found in the
Use ADB to connect to my device and list packages
I ran these commands to ensure my device was correctly connected and list all the available packages:
- /home/user/Android/Sdk/platform-tools/adb devices
* daemon not running; starting now at tcp:5037 * daemon started successfully List of devices attached 5832555546523551 device
- /home/user/Android/Sdk/platform-tools/adb shell pm list packages
... package:com.amazon.kindle package:com.google.android.apps.restore package:com.samsung.android.app.vr.input.service package:com.instantpot.app ...
- /home/user/Android/Sdk/platform-tools/adb shell pm list packages | grep -i instant
Get the package path and pull down the APK
- /home/user/Android/Sdk/platform-tools/adb shell pm path com.instantpot.app
- /home/user/Android/Sdk/platform-tools/adb pull /data/app/com.instantpot.app-bbb_fikgz0fAxuyjXwRCcc==/base.apk
/data/app/com.instantpot.app-bbb_fikgz.... 23.7 MB/s (46654418 bytes in 1.876s)
At this point I was able to start manipulating the Android application package.