androidadbapk

How do I get an apk file from an Android device?


How do I get the apk file from an android device? Or how do I transfer the apk file from device to system?


Solution

  • 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.