4

I am building an app that receives updates from a server. So at the beginning of the app, a download occurs. However, this thing is getting a bit annoying since whenever I want to test a new build, I would use:

adb -d uninstall com.mycompany.myapp

This command removes the app as well as its data/cache stored. Now, whenever I do this, I would have to go through the process of downloading the updates again and it takes time (a lot of it).

Is there an adb command that would uninstall the app without removing its data/cache? Eclipse ADT can do this but I don't want to fire up Eclipse everytime I build.

EDIT: I've tried using adb uninstall -k com.mycompany.myapp but it always responds with this:

The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell pm uninstall -k com.mycompany.myapp'

If I try adb shell pm uninstall -k com.mycompany.myapp it just says Failed.

3
  • Why can't you just provision your revised app as an update which installs over the new app? Commented Apr 2, 2014 at 6:51
  • How do I exactly do that?
    – Lance Gray
    Commented Apr 2, 2014 at 7:35
  • @LanceGray - update the version code in your AndroidManifest.xml Commented Jul 29, 2014 at 15:43

1 Answer 1

6

If you run adb with no arguments, the help text will tell you the answer to this question.

adb uninstall -k com.mycompany.myapp

removes the app but leaves the data and cache directories. Similarly,

adb install -r myapp.apk

reinstalls an existing app with a new APK file, keeping its data intact.

As a side-note, I don't know if this affects you, but don't forget that Google Play's developer terms forbids apps from updating themselves (updating the APK file) through a non-Google-Play channel. This is to stop developers side-stepping the Google Play terms by building a 'stub' app that, once installed, replaces itself with an app that doesn't meet the Google Play terms. Updating data files and the like is perfectly fine.

2
  • Thanks. Whenever I try adb uninstall -k com.mycompany.myapp, I get an error saying that it's not supposed to be used and if I really want to use it I should use the adb shell pm counterpart, which doesn't work on me. The app I'm building is not for Google Play, so I guess it's fine? Can you provide a link so that I can look more into it?
    – Lance Gray
    Commented Apr 2, 2014 at 10:25
  • The -r option works perfectly for me when I needed to update the apk of an app I have installed (with the same signature, mind you) without loosing all my data.
    – Allison
    Commented Aug 21, 2015 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .