Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Last active April 9, 2024 11:31
Show Gist options
  • Save ctrl-freak/24ac0e61b7cf550a6945 to your computer and use it in GitHub Desktop.
Save ctrl-freak/24ac0e61b7cf550a6945 to your computer and use it in GitHub Desktop.
Retrieve APK from Non-Rooted Android Device through ADB

https://stackoverflow.com/a/18003462/348146

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name (this may vary with the version of Android OS). The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. com.example.someapp. Skip this step if you already know the package name.

    adb shell pm list packages

    Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

  2. Get the full path name of the APK file for the desired package.

    adb shell pm path com.example.someapp

    The output will look something like this: package:/data/app/com.example.someapp-2.apk

  3. Pull the APK file from the Android device to the development box.

    adb pull /data/app/com.example.someapp-2.apk

@renozion
Copy link

Friends, sorry for any inconvenience, i was able to get the dump file on windows using version 1.3.0 of adb-setup.exe

@ctrl-freak
Copy link
Author

Friends, sorry for any inconvenience, i was able to get the dump file on windows using version 1.3.0 of adb-setup.exe

Glad to hear; if you have trouble in the future, you might find the XDA Developers forums a useful place to work through things like this.

@biblia19
Copy link

biblia19 commented Apr 8, 2024

To extract an app installed from the play store on a Galaxy Tab A Running Android 9 I used the following command from a git bash shell:

$ adb shell "pm list packages -f" | grep video

which returned this data: package:/data/app/com.samsung.android.videolist-g6xTrW8SV-TC1mpyial9WA==/base.apk=com.samsung.android.videolist

and this command successfully retrieved it: adb pull /data/app/com.samsung.android.videolist-g6xTrW8SV-TC1mpyial9WA==/base.apk 1 file pulled. 27.9 MB/s (5924177 bytes in 0.202s)

This Android Package Browser was useful because it showed the actual name of the APK was formatted as: folders+ base name + guid({g6xTrW...})+ "==/base.apk"

meaning the actual filename to be pulled is apparently: /data/app/com.samsung.android.videolist-g6xTrW8SV-TC1mpyial9WA==/base.apk

This still work on Android 14.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment