17

I'm about to publish a new version of an app to the Market. In order to avoid any potential problems once its been pushed to the Market and people get notified of an update, I'd like to simulate that process on my phone using the .apk for the new version of the app I'll be publishing.

For instance, it has an update to the SQLite DB it's using.

The closest I can find is using the Android Debug Bridge (adb) using the command: adb install C:\myApplication.apk with my phone attached to my PC via the usb cable. (the parameter represents wherever your apk file is on your PC).

When I do this, if the app is already installed on my phone, I get an error message:

Failure INSTALL FAILED ALREADY EXISTS.

If I delete the existing app from my phone, the adb install command works fine. So, it looks like this can only be used to install an app that doesn't currently exist on your phone.

Is there any way to simulate the update process? It'd be nice if there was an adb update command, but I don't see that.

Richard Le Mesurier
  • 27,993
  • 19
  • 127
  • 242
charlest
  • 905
  • 2
  • 10
  • 20

3 Answers3

32

Try using option -r to adb install:

adb install [-l] [-r] [-s] - push this package file to the device and install it ('-l' means forward-lock the app) ('-r' means reinstall the app, keeping its data) ('-s' means install on SD card instead of internal storage)

Heiko Rupp
  • 28,212
  • 13
  • 79
  • 118
  • Thanks! That took care of it. I was looking at the options for install on the Google site: running the actual command on my PC showed the options you mentioned. One thing I did find: if you try to replace it with a .apk that was signed with a different keystore, you'll get the error message: INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES. So, the only restriction is that you have to replace it with a .apk that was signed with the same certificate. – charlest Feb 14 '11 at 16:21
  • @charlest Great. The signing thing is a security measure. Basically it means to keep old versions around for upload to the device and then (incremental) upgrade testing. – Heiko Rupp Feb 14 '11 at 18:55
  • 1
    This is correct, as the `-r` option preserves the database file for the app. When the upgraded app is run for the first time, the database helper takes over, calling `onUpdate()` as required for testing. – Richard Le Mesurier Aug 13 '15 at 20:20
2

The closest I think you can get is to put the APK somewhere, and download it on a phone. That is about the closest you can get to the real market situations, with the only difference being that you need to add the "unknown sources" option.

(on a sidenote: you can get an error installing an apk with the same package-name, but a different signing.)

Richard Le Mesurier
  • 27,993
  • 19
  • 127
  • 242
Nanne
  • 61,952
  • 16
  • 112
  • 157
1

I think your error is because you have the market signed version installed and your trying to install a debug signed version. If you sign it with your market key it should install fine.

FoamyGuy
  • 45,328
  • 16
  • 118
  • 151
  • This is not true. If the app is already installed, no matter the signing key, `adb install` requires the `-r` option in order to install correctly. And if the signing key is wrong, you get the error INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES [as mentioned in comment by @charlest below](http://stackoverflow.com/questions/4993946/how-to-test-what-will-happen-when-you-publish-an-update-to-your-app-to-the-marke#comment5580744_4994089). – Richard Le Mesurier Aug 13 '15 at 12:15