How do I get the apk file from an android device? Or how do I transfer the apk file from device to system?
From the Google Play Store, copy the URL of the app you want to extract. Next, head to this web tool in your browser and paste the URL. Select “Generate Download Link.” This web app will then automatically extract the APK file and provide you with the relevant link to access it.
If you want to locate the APK files in your Android phones, you can find the APK for user-installed apps under /data/app/directory while the preinstalled ones are located in /system/app folder and you can access them by using ES File Explorer.
apk? For normal apps, there are stored in internal memory in /data/app. Some of the encrypted apps, the files are stored in /data/app-private. For apps stored in the external memory, files are stored in /mnt/sdcard/Android/data.
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. On more recent versions of Android (Oreo and Pie), an unpredictable random string is appended. 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
package:/data/app/com.example.someapp-2.apk
or
package:/data/app/com.example.someapp-nfFSVxn_CTafgra3Fr_rXQ==/base.apk
3) Using the full path name from Step 2, pull the APK file from the Android device to the development box.
adb pull /data/app/com.example.someapp-2.apk path/to/desired/destination
Use adb. With adb pull you can copy files from your device to your system, when the device is attached with USB.
Of course you also need the right permissions to access the directory your file is in. If not, you will need to root the device first.
If you find that many of the APKs are named "base.apk" you can also use this one line command to pull all the APKs off a phone you can access while renaming any "base.apk" names to the package name. This also fixes the directory not found issue for APK paths with seemingly random characters after the name:
for i in $(adb shell pm list packages | awk -F':' '{print $2}'); do adb pull "$(adb shell pm path $i | awk -F':' '{print $2}')" mv base.apk $i.apk &> /dev/null done
If you get "adb: error: failed to stat remote object" that indicates you don't have the needed permissions. I ran this on a NON-rooted Moto Z2 and was able to download ALL the APKs I did not uninstall (see below) except youtube.
adb shell pm uninstall --user 0 com.android.cellbroadcastreceiver <--- kills presidential alert app!
(to view users run adb shell pm list users) This is a way to remove/uninstall (not from the phone as it comes back with factory reset) almost ANY app WITHOUT root INCLUDING system apps (hint the annoying update app that updates your phone line it or not can be found by grepping for "ccc")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With