1

I had built an android application in eclipse. I have stored the keystore and key alias after publishing it. Now I have imported it in Android Studio, updated the source code. And I want to publish the update on play store, but unfortunately it is not accepting. The message is :

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: 01:C0:25:50:B5:86:5A:6F:E0:7D:67:4F:84:12:47:5F:3F:33:A2:51 ] and the certificate(s) used to sign the APK you uploaded have fingerprint(s): [ SHA1: CD:DE:F8:94:2C:EF:D7:DE:59:62:8E:63:B3:38:D5:32:1B:FF:37:A9 ]

Do I need to add the following code in my app module?

defaultConfig { ... }
signingConfigs {
    release {
        storeFile file("myreleasekey.keystore")
        storePassword "password"
        keyAlias "MyReleaseKey"
        keyPassword "password"
    }
}

Any help is really appreciated. Thanks

Developer110
  • 182
  • 7

1 Answers1

2

What I do to sign my release APKs is drop a copy of the actual relase.keystore file into the root of my project, then sign with command line. If you do it this way, you'll be 100% sure that you are signing your app with the actual keystore you signed it with in Eclipse.

So copy and paste a copy of your release.keystore file into the root of your Android Studio project, then using command line navigate to that directory, then run this command:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore your_release_key.keystore app/build/outputs/apk/your_unsigned.apk your_release_key_alias

This assumes you have the jarsigner added to your PATH environment variable. Also, you'd obviously replace the file names with the actual file names of your keystore and your apk.

Hope this helps!

NoChinDeluxe
  • 3,446
  • 1
  • 16
  • 29
  • jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 10214 but got 10426 bytes) getting this @drschultz – Developer110 Oct 16 '15 at 14:38
  • You are trying to resign an APK that is already signed. Make sure you export a fresh, unsigned APK, then try it again on that. – NoChinDeluxe Oct 16 '15 at 14:41
  • which apk is not signed? i mean there are three apks in the path .../outputs/apk – Developer110 Oct 16 '15 at 14:44
  • Whichever one you plan to release ;) You should name your release APK build with a version number or something to identify it. Your other option would be to just delete the apk folder and then build the release APK again, and it should create a fresh apk folder with nothing in it but your new build. – NoChinDeluxe Oct 16 '15 at 14:52
  • thanks for your help... but i am getting the same error... i deleted the apk folder, generate the new apk, and this was my command line jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore developer110.jks app/build/outputs/apk/app-debug.apk developer110 – Developer110 Oct 16 '15 at 15:00
  • probably i should use app-release apk instead of debug...... can u tell me from where can i get that apk? @drschultz – Developer110 Oct 16 '15 at 15:01
  • 1
    Yes, you need to build release, not debug. Delete the APK folder again, then run this from the root of your project: `./gradlew clean assembleRelease`. This should produce a release apk named something similar to `app-release-unsigned.apk` – NoChinDeluxe Oct 16 '15 at 15:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92554/discussion-between-developer110-and-drschultz). – Developer110 Oct 17 '15 at 03:06
  • I build an unsigned release apk . signed it then aligned that apk using zipalign. then uploaded. But it is still showing me the same error. i have mailed the issue to google. until then if you have any alternative plz let me know – Developer110 Oct 17 '15 at 12:48