262

I'm trying to extract the APK file of an installed Android app WITHOUT root permissions.

I thought that this was impossible, because all APK files for non-system-apps are located in /data/app, and accessing this folder requires root permission. Then I found that there are numerous apps in the Google Play store that seem to have access to the APK files even on non-rooted devices.

Can someone tell me how this is possible? Aren't there backup apps which backup the APK files without root?

TylerH
  • 20,799
  • 66
  • 75
  • 101
pinas
  • 2,708
  • 4
  • 21
  • 33
  • 2
    I think this question is already answered. Kindly give a look at http://stackoverflow.com/a/12197924/1016544 – Wahib Ul Haq Dec 22 '12 at 21:03
  • 1
    http://stackoverflow.com/questions/7632156/can-i-get-apk-file-in-phone-of-the-installed-applications – gliptak Jan 16 '13 at 22:58
  • 2
    Possible duplicate of [How do I get an apk file from an Android device?](http://stackoverflow.com/questions/4032960/how-do-i-get-an-apk-file-from-an-android-device) – Ciro Santilli OurBigBook.com Aug 25 '16 at 12:21
  • 1
    Possible duplicate of [where can i find the .apk file on my device, when i download any app and install?](https://stackoverflow.com/questions/12175904/where-can-i-find-the-apk-file-on-my-device-when-i-download-any-app-and-install) – NoWar Jul 07 '17 at 05:46
  • 3
    My reading of this is that @pinas was asking how to code this programatically - referencing apps that do it as if to say "These apps do it, but how?". The "on hold" reason here is wrong in my opinion because of that. – Richard Le Mesurier Jul 30 '18 at 13:35
  • I think the last sentence seems to suggest he is looking for a backup app he can use without root. The answer he accepted suggests otherwise. In any case if reopened it should be reworded to be unambiguous – Nick Cardoso Jul 30 '18 at 13:51

11 Answers11

482

Accessing /data/app is possible without root permission; the permissions on that directory are rwxrwx--x. Execute permission on a directory means you can access it, however lack of read permission means you cannot obtain a listing of its contents -- so in order to access it you must know the name of the file that you will be accessing. Android's package manager will tell you the name of the stored apk for a given package.

To do this from the command line, use adb shell pm list packages to get the list of installed packages and find the desired package.

With the package name, we can get the actual file name and location of the APK using adb shell pm path your-package-name.

And knowing the full directory, we can finally pull the adb using adb pull full/directory/of/the.apk. The APK file gets stored to the directory from which you run your console.

Credit to @tarn for pointing out that under Lollipop, the apk path will be /data/app/your-package-name-1/base.apk

OneWorld
  • 17,512
  • 21
  • 86
  • 136
mah
  • 39,056
  • 9
  • 76
  • 93
  • 35
    To do this from the command line, use `adb shell pm list packages` to get the list of installed packages, pick the desired package, append `-1.apk` to it, and pull it from `/data/app`. Example: If the package name is `org.mozilla.firefox`, use `adb pull /data/app/org.mozilla.firefox-1.apk`. – sschuberth Jun 07 '13 at 12:16
  • 13
    To get the actual file name of the APK, use adb shell pm path your-package-name. See this question for a more detailed answer http://stackoverflow.com/questions/4032960/how-do-i-get-an-apk-file-from-an-android-device – Yojimbo Sep 10 '13 at 03:43
  • 2
    for lollipop the apk path will be /data/app/your-package-name-1/base.apk – tarn Sep 16 '16 at 10:46
  • This doesn't work for me. I get the following error: `adb: error: remote object '/data/app/com.Slack-1/base.apk' does not exist` – 0xcaff Aug 11 '17 at 02:12
  • 1
    @0xcaff Android has changed quite a bit in the 5 years since this answer was provided; perhaps this path is one of those changes. You should be able to log in and locate the file manually in order to come up with whatever path is appropriate for your version of the os. – mah Aug 11 '17 at 02:16
  • I used `adb shell pm path com.Slack` to find the package name. – 0xcaff Aug 11 '17 at 02:24
  • `adb pull /data/app/com.company.appname-1` worked for me [remove .apk at the end] – Anton Kasabutski Nov 13 '17 at 23:59
  • `adb shell "pm list packages -f | grep app-name"` will give you the package name and the APK path in one go. – TWiStErRob Dec 21 '17 at 12:42
  • 1
    It works! On Windows I use PowerShell with the same commands, and after 'adb pull full/directory/of/the.apk' I can find the.apk in my default foder C:\Users\myName\the.apk – Krzysztof Walczewski Jan 24 '20 at 10:04
  • `Permission denied`... – Fnr Nov 16 '21 at 19:42
  • I love you! Just recovered an old game I had developed and it was lost in an old broken tablet of mine where just half the screen worked hehehe amazing! – Pablo Camara Aug 28 '23 at 20:01
74

Android appends a sequence number to the package name to produce the final APK file name (it's possible that this varies with the version of Android OS). The following sequence of commands works on a non-rooted device:

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

    adb shell pm path com.example.someapp
    

    This gives the output as: package:/data/app/com.example.someapp-2.apk.

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

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

The location of APK after successful pulling will be at ../sdk/platform-tools/base.apk on your pc/laptop.

Zeeshan
  • 1,625
  • 17
  • 25
Yojimbo
  • 23,288
  • 5
  • 44
  • 48
  • 8
    Can confirm this solution worked on a non rooted device, though does require knowledge of the package name prior to the first command! Use 'adb shell pm list packages' to get a list of all packages on the phone incase you aren't sure of the package name of your desired app – AndroidNoob Nov 03 '14 at 12:31
  • 1
    What folder on the puller's local machine does the apk go into? EDIT: nvm, whatever directory you were in when doing the adb pull... – Adam Johns Jun 14 '16 at 13:03
  • @IgorGanapolsky try using adb pull /data/app/com.example.someapp-2/base.apk – Chris - Jr Sep 29 '17 at 20:38
  • @zelanix after doing adb pull, where i can c the .apk file. Thank you – Vijaya Varma Lanke Aug 17 '18 at 16:43
  • I found the apk location in the project build view on Android Studio. – Andrew Chelix Nov 10 '20 at 18:13
13

On Nougat(7.0) Android version run adb shell pm list packages to list the packages installed on the device. Then run adb shell pm path your-package-name to show the path of the apk. After use adb to copy the package to Downloads adb shell cp /data/app/com.test-1/base.apk /storage/emulated/0/Download. Then pull the apk from Downloads to your machine by running adb pull /storage/emulated/0/Download/base.apk.

Buhiire Keneth
  • 1,392
  • 14
  • 11
  • Work great for me whereas the other methods fails on a non rooted device. I could use an app as MyAppSharer but I prefer this scriptable method. – Stéphane Padovani Oct 25 '21 at 14:11
7
  1. check the list of installed apk's (following command also list the path where it is installed and package name). adb shell pm list packages -f
  2. use adb pull /package_path/package name /path_in_pc (package path and package name one can get from above command 1.)
Abhishek
  • 306
  • 2
  • 8
7

I got a does not exist error

Here is how I make it works:

adb shell pm list packages -f | findstr zalo

package:/data/app/com.zing.zalo-1/base.apk=com.zing.zalo

adb shell

mido:/ $ cp /data/app/com.zing.zalo-1/base.apk /sdcard/zalo.apk
mido:/ $ exit


adb pull /sdcard/zalo.apk Desktop

/sdcard/zalo.apk: 1 file pulled. 7.7 MB/s (41895394 bytes in 5.200s)
vanduc1102
  • 5,769
  • 1
  • 46
  • 43
6

When you have Eclipse for Android developement installed:

  • Use your device as debugging device. On your phone: Settings > Applications > Development and enable USB debugging, see http://developer.android.com/tools/device.html
  • In Eclipse, open DDMS-window: Window > Open Perspective > Other... > DDMS, see http://developer.android.com/tools/debugging/ddms.html
  • If you can't see your device try (re)installing USB-Driver for your device
  • In middle pane select tab "File Explorer" and go to system > app
  • Now you can select one or more files and then click the "Pull a file from the device" icon at the top (right to the tabs)
  • Select target folder - tada!
anon
  • 69
  • 1
  • 1
2

Open ES explorer -> push Menu button at the left upper corner (three horizontal stripes) -> in the Libraries section choose APPs.

Thus, you get the list of all the user apps. Find your app and select it with long pushing on it. Then press "More" in the right low corner and choose "Send". Then you can use different options, e.g. you can choose "ES Save To" in order to save the .apk file to your home directory or anywhere else.

JenyaKh
  • 2,040
  • 17
  • 25
  • Simpliest non-technical solution IMO. Worked for me on a Galaxy Tab A (2016) using app named "ES File Manager | File Explore" from GreenSoft Infotech. Thanks – Maxime T Nov 05 '22 at 09:56
1

Obtaining an APK file of an installed app is possible via the free and open-source Ghost Commander app, which is available on both F-Droid and the Play Store.

In the Ghost Commander app, go to Apps, then simply long-tap an app from the list and choose Copy. The .apk file will be available in the other file panel; you can put it wherever you want.

Note that, since Ghost Commander is a two-panel file manager, you first have to use the other panel and open a folder there (which is where we want to copy the apk file into). Then, go to the other panel and go to Apps there.

(If you don't see 'Apps', first tap the arrow and select Home.)

Links:

  1. https://f-droid.org/packages/com.ghostsq.commander/
  2. https://sourceforge.net/projects/ghostcommander/
  3. https://play.google.com/store/apps/details?id=com.ghostsq.commander
Jelle Geerts
  • 833
  • 8
  • 12
0

I found a way to get the APK's package name in a non-root device. it's not so elegant, but works all the time.

Step 1: on your device, open the target APK

Step 2: on PC cmd window, type this commands:

 adb shell dumpsys activity a > dump.txt

because the output of this command is numerous, redirect to a file is recommended.

Step 3: open this dump.txt file with any editor.

for device befor Android 4.4:
the beginning of the file would be looked like this:

ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)  
  Main stack:  
  * TaskRecord{41aa9ed0 #4 A com.tencent.mm U 0}  
    numActivities=1 rootWasReset=true userId=0  
    affinity=com.tencent.mm  
    intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10600000 cmp=com.tencent.mm/.ui.LauncherUI}  
    realActivity=com.tencent.mm/.ui.LauncherUI  
    askedCompatMode=false  
    lastThumbnail=null lastDescription=null  
    lastActiveTime=19915965 (inactive for 10s)  
    * Hist #9: ActivityRecord{41ba1a30 u0 com.tencent.mm/.ui.LauncherUI}  
        packageName=com.tencent.mm processName=com.tencent.mm 

the package name is in the 3rd line, com.tencent.mm for this example.

for Android 4.4 and later:
the dumpsys output has changed a little. try search "Stack #1", the package name would be very close below it.

Also, search "baseDir", you will find the full path of the apk file!

Swing
  • 858
  • 1
  • 8
  • 21
0

One line command, with separated download to paths by packages

SEARCH_APP="minecraft" && PKGS=$(adb shell pm list packages | grep ${SEARCH_APP}) && for PKG in ${PKGS}; do PKG=${PKG#*:} && mkdir -p ${SEARCH_APP}/${PKG} && PKG_FILES=$(adb shell pm path ${PKG}) && for PKG_FILE in ${PKG_FILES}; do PKG_FILE=${PKG_FILE#*:} && adb pull $PKG_FILE ${SEARCH_APP}/${PKG}; done; done
Ninazu
  • 151
  • 6
-2

Or you can get 'Bluetooth File Transfer' from Google Play and set the home folder to /system/ . Then you can even go to / .

Rohan
  • 52,392
  • 12
  • 90
  • 87
AJD
  • 5
  • 1