Migrate AIR Android p12 keystore file to Cordova
Asked Answered
O

1

1

At the time of our initial AIR app for Android release, we generated a .p12 keystore file using openssl, and ever since we have been signing our Android app with this file and a pw before submitting it to the Google Play Store. We build our apk thus:

java adt.jar -storetype pkcs12 -keystore {our-p12} -storepass {our-pw} ....

We are now migrating to Cordova.

We have imported our p12 into a new keystore file following the instructions here Signing apk with .p12. We use the following command to import our p12 into an empty keystore file:

keytool -importkeystore -srckeystore {our-p12} -destkeystore viacordova.keystore -srcstoretype pkcs12

However, when we try to upload our Cordova app to Google, we get the following error:

Upload failed

You uploaded an APK that is signed with a different certificate to your previous APKs. You must use the same certificate. Your existing APKs are signed with the certificate(s) with fingerprint(s):

[ SHA1: {list of bytes} ]

and the certificate(s) used to sign the APK you uploaded have fingerprint(s):

[ SHA1: {different list of bytes} ]
Orthoscope answered 8/6, 2017 at 20:22 Comment(1)
Did you ever solve this? I am facing the same issue :(Fayre
F
1

If anyone lands here facing the same issue, this is how I solved it.

The issue at heart is that the original .p12 file is super old (2012 for me) and was created with jdk1.7 and adobe air. Using later versions of jdk seem to mess with the fingerprint.

However I discovered you don't actually need to do anything with your existing .p12 but you do need to use jdk1.7 to sign the app. Using Cordova to sign the app won't work and will complain about the .p12

The below steps allowed me to sign my Cordova Android app and successfully submit it as an update on google play with an existing .p12 cert created with adobe air.

First build an unsigned release version of your android app using latest Cordova and dependencies etc.

cordova build android --release

Navigate to a jdk1.7 bin directory, in my case on windows it was: C:\Program Files\Java\jdk1.7.0_03\bin and now sign your app with jdk1.7 jarsigner.

jarsigner -keystore PATH_TO/your_original.p12 -storetype pkcs12 PATH_TO/app-unsigned.apk 1

Now you just need to use zipalign with this command. Using latest zipalign in Android\Sdk\build-tools works OK.

zipalign -f -v 4 app-unsigned.apk app-signed.apk

Now you can upload your .apk to google play store.

Related (but still ended in wrong fingerprint for me): Sign Android Native apk with Adobe Air certificate

Fayre answered 7/10, 2019 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.