11 September, 2010

Journey of Android Development -- Install/Reinstall/Uninstall Apps

As I've mentioned in previous posts, I'm starting along a journey of developing applications for the Android phone. I figure I'll likely post some of my findings along the way for your amusement.

The first thing I was kinda surprised at was the fact that the Android Emulators are persistent, meaning that if you install an application it persists through emulator power cycle. Sure, sure it's certainly understandable that they are attempting to emulate a true phone which persists through power cycle but I was surprised this was the default behavior.

The relevance is that in the fashion of incremental development you'll find yourself coding a little, testing a little,... That manner requires you to install your app numerous times for testing. You'll quickly find that you need to uninstall the previous version to install the latest.

You install your app by applying a command similar to the following:

user@debian:~/Buttons$ adb -s emulator-5554 install ./bin/Buttons-debug.apk
98 KB/s (4384 bytes in 0.043s)
pkg: /data/local/tmp/Buttons-debug.apk
Success


An attempt to reinstall will fail due to the application already existing.

user@debian:~/Buttons$ adb -s emulator-5554 install ./bin/Buttons-debug.apk
98 KB/s (4384 bytes in 0.043s)
pkg: /data/local/tmp/Buttons-debug.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]


You can remedy that by forcing an overwrite.

user@debian:~/Buttons$ adb -s emulator-5554 install -r ./bin/Buttons-debug.apk
95 KB/s (4384 bytes in 0.044s)
pkg: /data/local/tmp/Buttons-debug.apk
Success


Alternatively, you can remove the application explicitly

user@debian:~/Buttons$ adb shell rm data/app/com.example.buttons.apk

No comments: