Android aplication: How to extract an APK file and reinstall it


We are going to find an Android application and extract its APK file.

After that we will reinstall it.


List installed packages and find the app name


This adb command list all installed applications in your phone.

$ adb shell pm list packages
package:com.firestudio.movietube
package:com.tmsoft.whitenoise.lite
package:com.skype.raider
package:com.halfbrick.jetpackjoyride
package:com.aob.android.mnm
package:com.farproc.wifi.analyzer
package:com.android.providers.telephony
package:com.bigduckgames.flow
package:com.google.android.googlequicksearchbox
....



There are a lot, so another way to find the application name is using a web browser, going to Google Play and finding there the app.

The URL contains the app name:

E.g: https://play.google.com/store/apps/details?id=com.psa.sa

The app name I am looking for is com.psa.sa.



Other way, when installing the app I could perform a diff in the list:
$ adb shell pm list packages > list_pre.txt
Install the app
$ adb shell pm list packages > list_post.txt
$ diff list_pre.txt list_post.txt
95a96
> package:com.psa.sa



Find the application actual path to extract it


Find the path of the application file:
$ adb shell pm path com.psa.sa
package:/data/app/com.psa.sa-1/base.apk

Extract the APK file to your hard disk:
$ adb pull /data/app/com.psa.sa-1/base.apk
3783 KB/s (4785000 bytes in 1.235s)


We get base.apk file.


Install the app from the APK file


To install the app:
$ adb install -s base.apk
3403 KB/s (4785000 bytes in 1.372s)
pkg: /sdcard/tmp/base.apk
Success


or uninstall it:

$ adb uninstall com.psa.sa
Success


REFERENCE


http://stackoverflow.com/questions/4032960/how-do-i-get-an-apk-file-from-an-android-device

Android: How to install adb and fastboot in Debian