clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

May need to uninstall APK before to install APK on Android device #46

Closed ayamada closed 11 years ago

ayamada commented 11 years ago

Hi.

This code was comment-outed, but it is necesally because adb install fails when old APK's private key discord from new APK's private key. It is occur when old APK is debug version and new APK is release version, and vice versa. because debug version was signed by key for debug, but release version was signed by key for release.

Below is this error log.

Applying task droid to (install)
Installing APK...
d:path\to\android-sdk\platform-tools\adb.exe devices
List of devices attached
275501710050095 device

d:\path\to\android-sdk\platform-tools\adb.exe -s 275501710050095 install -r d:\path\to\project\target/appname-debug.apk
        pkg: /data/local/tmp/appname-debug.apk

Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

1196 KB/s (4012547 bytes in 3.276s)

If not installed old APK, then fail to adb uninstall, but it is not do anything but display Failure. It seems harmless.

alexander-yakushev commented 11 years ago

Hello Atsuo!

Yes, first I went with uninstalling, but then I commented it for the following reason - after uninstallation all application data is lost. It is quite annoying when you develop and keep some data in the application (DB, SharedPreferences etc, custom files etc.).

I think, this should be handled in a more intelligent way. Thank you for the heads-up nonetheless, I will push a solution soon.

ayamada commented 11 years ago

Hello Alexander!

Oh... I understand. It's just as you say. I'm sorry for took up your time, and thank you!

alexander-yakushev commented 11 years ago

Atsuo,

Your input is very helpful and well appreciated. This is a bug and I thank you for discovering it. I've made a fix that should resolve the issue. I now try to install the application first, and if it fails because of the certificate mismatch, user is prompted if he wants to replace the application.

Could you please try it out? Thank you!

ayamada commented 11 years ago

Hi, Alexander!

I try this fix, but I got Abort execution.. I use lein-droid on Windows, that is differ linefeed code, and adb output log like below.

d:\path\to\android-sdk\platform-tools\adb.exe -s 275501710050095 install -r d:\path\to\project\target/myapp-debug.apk
        pkg: /data/local/tmp/myapp-debug.apk

Success

1287 KB/s (4012341 bytes in 3.043s)

I try to fix this, and it work on Windows. I send it later.

Your approach for this issue is very excellent! It is very convenience. Thank you!