writofmandamus
writofmandamus

Reputation: 1231

How to install over existing Android app on device using adb?

During development, I use something like

$ adb -s 192.168.1.77:5555 uninstall com.myApp.app

$ adb -s 192.168.1.77:5555 install /path/to/android-debug.apk

to uninstall the existing app, then push and install the updated app to my device. However, this seems to erase my existing data associated with the app so that each time I run the updated app I need to input the new data again. However, simply running the install command gives:

[ 10%] /data/local/tmp/android-debug.apk
[100%] /data/local/tmp/android-debug.apk
    pkg: /data/local/tmp/android-debug.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]

With iOS you can simply install your updated app over the existing app on the device.

What is the equivalent for Android preferably using adb?

Edit: This question is really similar to this one, but I think this should be kept because the way my question is phrased will help many people trying to find an answer that are coming from a different angle– the angle being of reinstalling/overwriting versus updating.

Upvotes: 3

Views: 8211

Answers (1)

ymonad
ymonad

Reputation: 12090

from adb --help

adb install [-lrtsdg] <file>
        - push this package file to the device and install it
         (-l: forward lock application)
         (-r: replace existing application)
         (-t: allow test packages)
         (-s: install application on sdcard)
         (-d: allow version code downgrade (debuggable packages only))
         (-g: grant all runtime permissions)

Therefore you can just add -r option

$ adb -s 192.168.1.77:5555 install -r /path/to/android-debug.apk

Upvotes: 8

Related Questions