54

How do I test an update of my application, versus a clean install? I see that adb install has several flags, but I'm not sure which one mimics reality.

I explicitly need to test app updating.

Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406

1 Answers1

97

You don't need to re-install to get a 'clean install', you can just wipe the application's data.

Go to Settings > Applications > Find your app and use 'clear data' (or similar). At that point your app won't know the difference unless you are also using files on the SD card.

And, of course, app updating can be tested by installing normally (or, with adb, you can use adb install -r for installing while keeping the app's data, as you would on the market or with an APK)

HXCaine
  • 4,228
  • 3
  • 31
  • 36
  • 28
    `adb install -r` is the ticket. – Stefan Kendall Jan 22 '12 at 17:07
  • 7
    Actually, it's not. localstorage is wiped when the app store updates, but it's preserved when I run `adb install -r`. This isn't right. – Stefan Kendall Jan 22 '12 at 17:16
  • 2
    When you update from the market your app should keep all its 'shared preferences'. It would make no sense to wipe your data when you update your app to a new version, and I'm sure you know that your apps don't do that – HXCaine Jan 22 '12 at 22:08
  • As it turns out, updating apps *can* wipe localStorage. You just need to account for this. – Stefan Kendall Jun 18 '12 at 16:45
  • 10
    @StefanKendall In what cases would the local storage be wiped? – HXCaine Jun 26 '12 at 22:10
  • 1) if not done so already, set adb location in Path System variable as described here https://stackoverflow.com/questions/20564514/adb-is-not-recognized-as-an-internal-or-external-command-operable-program-or/ 2) you need to reference the apk file: "adb install -r " – hmac Oct 12 '17 at 10:01
  • `adb` is so stupid. Once I forgot `-r` or `-u`. I put `-u`, it started to transfer apk to my phone and only after that it printed `Error: Unknown option: -u` – user25 Feb 09 '19 at 21:15