{"id":4190,"date":"2022-04-15T11:10:15","date_gmt":"2022-04-15T16:10:15","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4190"},"modified":"2022-04-15T11:17:18","modified_gmt":"2022-04-15T16:17:18","slug":"using-adb-to-pull-apks-off-device","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/using-adb-to-pull-apks-off-device\/","title":{"rendered":"Using ADB to Pull APKs off Device"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"468\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image-1024x468.png\" alt=\"\" class=\"wp-image-4413\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image-1024x468.png 1024w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image-300x137.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image-768x351.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image-500x228.png 500w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/04\/image.png 1233w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>ADB Help for pull and shell<\/figcaption><\/figure>\n\n\n\n<p>It is sometimes helpful to pull an APK from a working device so you can install it on a different device.  These commands should work on an emulator, phone, tablet, or other Android device.  You just need to be able to connect with ABD.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Connect to device with ADB<\/li><li>View installed apps<\/li><li>Find path for APK<\/li><li>Pull\/Download APK<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">View Installed Apps<\/h2>\n\n\n\n<p>This will display a list of all the installed packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adb shell pm list packages <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Find path for specific App\/APK<\/h2>\n\n\n\n<p>Replace com.android.apk with the app of interest.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adb shell pm path com.android.apk<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Pull APK to local machine<\/h2>\n\n\n\n<p>Pull\/Download the APK of interest to your local machine with the following command.  Change the path &#8220;\/data\/app\/&#8230;&#8221; to the path returned from the previous command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adb shell pull \/data\/app\/info\/base.apk<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>You can view the following link for more information.<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/4032960\/how-do-i-get-an-apk-file-from-an-android-device\">https:\/\/stackoverflow.com\/questions\/4032960\/how-do-i-get-an-apk-file-from-an-android-device<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Advanced Tricks<\/h1>\n\n\n\n<p><em>What if you need to get an APK off a secondary profile, or would like to download all the APKs off a system?  And what about split APKs?<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Multiple User Profiles<\/h2>\n\n\n\n<p>Run the following command to list the users.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adb shell pm list users<\/pre>\n\n\n\n<p>Example return<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Users:\n        UserInfo{0:User:a41} running\n        UserInfo{11:User:439} running<\/pre>\n\n\n\n<p>In this case our second user id is 11.  To get a list of APKs installed for our second user we would specify the &#8211;user= option<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adb shell pm list packages --user=11<\/pre>\n\n\n\n<p>To get the path for the app we would run it with<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adb shell pm path --user=11 com.android.apk<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Split APKs<\/h2>\n\n\n\n<p>Split APKs can be slightly more difficult to manage, mainly due to the fact that there are multiple APKs to keep track of.  <\/p>\n\n\n\n<p>When you run the &#8220;pm path&#8221; command, it should return multiple APKs.  Use the pull command like normal, but download each APK.<\/p>\n\n\n\n<p>You&#8217;ll need to use a split APK installer to install all the APKs.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PowerShell script for Pulling\/Downloading all APKs on Device<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>The following PowerShell script will download all APKs for a specific user and put them in their own folders.  <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Copy the contents to a .ps1 file<\/li><li>Enable ps1 execution policy if not already enabled<\/li><li>Run PowerShell script.<\/li><\/ul>\n\n\n\n<p>This script will pull all the APKs off of a device and put them in the current folder.  <br>It will also download split APKs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># adbapkbackup uses adb to get a list of all the APKs you have on a phone and then\n# Creates folders for each app and downloads the APKs for those apps.\n\n# Copy and save code as a ps1 file\n\n# Enable ps1 scripts to run on your computer by launching an Admin promopt and running\n# set-executionpolicy remotesigned\n\n# If you are in a secondary profile, add and\/or modify\n#  \"--user 15\"\n# to your user id\n# adb shell pm list users\n\n# If in secondary profile, add \"--user 15\" after packages before &gt; apklist.txt\nadb shell pm list packages --user 15 &gt; apklist.txt\n\n $apks = ((Get-Content .\\apklist.txt)) -replace 'package:',''\n\n ForEach ($apk in $apks) {\n    echo \"APK is $apk\"\n    md $apk\n    # If in secondary profile, add \"--user 15\" after path, before $file\n    adb shell pm path $apk\n    $filepath = ((adb shell pm path --user 15 $apk | % {$_.replace(\"package:\",\"\")}))\n    ForEach ($lapk in $filepath | % {$_.replace(\"package:\",\"\")}) {\n        echo \"pulling $lapk $apk\"\n        adb pull $lapk $apk\n    }\n }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>It is sometimes helpful to pull an APK from a working device so you can install it on a different device. These commands should work on an emulator, phone, tablet, or other Android device. You just need to be able &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/using-adb-to-pull-apks-off-device\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[540],"tags":[581,541,1291,226,1292],"class_list":["post-4190","post","type-post","status-publish","format-standard","hentry","category-android","tag-adb","tag-android","tag-apk","tag-download","tag-pull"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4190"}],"version-history":[{"count":11,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4190\/revisions"}],"predecessor-version":[{"id":4420,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4190\/revisions\/4420"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}