views:

160

answers:

2

I have developed a small application that consists of 5 different apk files. I'm developing on a lot of PCs and have a lot of developing phones. Every time I change the PC, the signature of the generated APK file is changed and I have to uninstall the applications on the phone. This is very time consuming. So is there a possibility to write a batch/file script that i can run on the PC so that the defined applications are uninstalled on the device?

I tried to do it the following way:

for %%f in (adb devices) do (
adb -s %%f uninstall bla.bli.blub
)

But unfortunately it doesn't work correctly ;)

+1  A: 
  1. Open up a terminal
  2. cd to the directory where you've installed the android sdk
  3. cd tools/
  4. adb uninstall package-name
    (where package-name is something like com.android.blah)

And of course you can put these steps in a shell script and uninstall several packages.

Daniel Velkov
the problem is... i have different devices running and connected. do you know how i can go through the list of all available devices? I could hardcode them using the serial number of the device, but if this device is not connected, then there is a problem.
Roflcoptr
The you can run `adb devices` and get the device ids.
Daniel Velkov
thanks. can you help me how i can store this list and then make a loop whith it?
Roflcoptr
If you know Ruby, you could write a Ruby script that runs these shell scripts. Just have the shell scripts dump their results in a file and read it in Ruby. Then you'll have a much easier time with loops, etc.
Andy Zhang
Thanks for the hint, but unfortunately i dont know Ruby :(
Roflcoptr
+1  A: 

So I finally was able to get a working version of the script:

FOR /F "skip=1" %%P IN ('adb devices') DO (
adb -s %%P uninstall bla.blub.application1
adb -s %%P uninstall bla.blub.application2
)
Roflcoptr