views:

604

answers:

1

How do I sign an APK with more than one certificate, so that I can do this when I publish to the Android Market:

Version 1.0 => Signed with Certificate A
Version 2.0 => Signed with Certificate A & B
Version 3.0 => Signed with Certificate B

The Android Market does give me some hope but I am not sure what to make of it, when I upload with a different sign certificate it gives me this message:

"The apk must be signed with at least one certificate in common with the previous version."

Motive:
I have published an app on the market using the Android Signing Tool as part of MotoDev Studio for android. The problem is that it handles the keys itself and there is no way (documented) to get them. I want to change it to use a keystore and certificate that I have more control of and can use even if I don't use MotoDev Studio anymore. Also it seems that MotoDev Studio will lock you out of new features such as shared libraries.

+3  A: 

If you want to sign an APK more than once, just do so.

eg. You can sign an APK from the command line using jarsigner like so:
jarsigner -keystore original-keystore my-app-unsigned.apk key-alias alias

Then just repeat this with the second key:
jarsigner -keystore new-signing-keystore my-app-unsigned.apk key-alias

Don't forget to run zipalign afterwards:
zipalign -v 4 my-app-unsigned.apk my-app.apk


Just re-read the part about MotoDev studio. In that case you can just sign the APK first using MotoDev as usual, then sign with your new key on the command line as above.

Christopher
Ok I will see if the Android Market will accept it assigned with the old certificate then the new one and then upload another update with just the new one and see if it works. That is what I was thinking but I am new to code signing in general and it does not once mention a way to change certificates.
ddcruver
Well at least in the Android Docs.
ddcruver
Seems to work just fine, this seems to be THE way to change the certificate on an Android Market application.
ddcruver
Just wanted to update this, it works fine but ALL your users will have to uninstall and reinstall there applications in order to upgrade. This issue I assume needs to be address by the android market some time in the future. I wont be changing anymore of my certificate over because it is an annoyance to my customers.
ddcruver