Search code examples
androidcalabash

How to use customised keystore for Calabash-android?


I got the following log when I try to run the command "calabash-android resign xxx.apk"

calabash-android resign xxx.apk /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.4.21/lib/calabash-android/java_keystore.rb:27:in sign_apk': Could not sign app: /var/folders/d3/r6sv00v12z151kw0yq8vq9kc0000gn/T/d20140516-67726-1effki9/unsigned.apk (RuntimeError) from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.4.21/lib/calabash-android/helpers.rb:77:insign_apk' from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.4.21/lib/calabash-android/helpers.rb:57:in block in resign_apk' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:88:inmktmpdir' from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.4.21/lib/calabash-android/helpers.rb:51:in resign_apk' from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.4.21/bin/calabash-android:95:in' from /usr/bin/calabash-android:23:in load' from /usr/bin/calabash-android:23:in'


Solution

  • For the 'resign' command of calabash-android, it executes the following operations:

    zip my.apk -d 'META-INF/*'

    jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore xxx.apk androiddebugkey

    So we need to make sure everything of the customised debug.keystore is same as the jarsigner's requirement, the algorithm should be "MD5withRSA", the alias name should be "androiddebugkey" etc. Otherwise, you need to change your script file which path is /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.4.21/lib/calabash-android/java_keystore.rb