Android – How to get an apk file from an Android device

adbandroidapk

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

Best Answer

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