Skip to content

Instantly share code, notes, and snippets.

@aclegg2011
Forked from ctrl-freak/android-adb-pull-apk.md
Last active May 22, 2019 20:15
Show Gist options
  • Select an option

  • Save aclegg2011/c492fe0211ea14fa47ae16cfd4a15d6f to your computer and use it in GitHub Desktop.

Select an option

Save aclegg2011/c492fe0211ea14fa47ae16cfd4a15d6f 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

Thank you for the info, you can merge the 2 first commands in one using the -f option (which displays associated file) : adb shell pm list packages -f | grep someapp -> package:/data/app/com.example.someapp-2/base.apk=com.example.someapp

BTW, a useful trick to quickly find the associated package is to launch the app and find the displayed activity using this command : adb shell dumpsys activity top | grep ACTIVITY -> ACTIVITY com.example.someapp/.app.HomeActivity 2dbf6e2 pid=18453

@aclegg2011

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