Search code examples
androidintellij-ideasignjks

Generate signed APK after update Android Studio


I have really strange problem. Years ago I write an App which was written in Eclipse. Then I upgraded to Android Studio 0.4.3 Everything was work correctly but now I delete this AS and work with new version (Android Studio 141.xxxx).

The problem is, that I use the same JKS certificate, but after upload to Google Play Store I see communicate about difference in finger print.

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: D0:D9:BE:8B:D2:6A:5F:xxxxxxxxxxxxxxxxxxxx:F4:D9:91:66:06:12 ]

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

[ SHA1: DA:53:9F:A7:D3:3C:8D:xxxxxxxxxxxxxxxxxxxx:CE:1F:F2:AB:0B:64 ]

I tried sign my app manual but then I have this communicate.

Upload failed You uploaded an APK with invalid or missing signing information for some of its files. You need to create a valid signed APK. Learn more about signing.

Anyone have an idea? Here is similar question but without answer.


Solution

  • Okey... Finally I resolve this Issue. But I still don't know why it occurs.

    Firstly I make sure that I use the same jks before

    jarsigner -verify -verbose:summary -certs old.apk
    jarsigner -verify -verbose:summary -certs new.apk
    

    Certificates looks the same. So I build my application and sign this with my certificate. But it doesn't work.

    So I made it manually

    1. I open my apk file with WinRAR and then, delete META-INF dir from app-release-unaligned.apk (app\build\outputs\apk in my case)
    2. Paste zipalign.exe to folder with my app-release-unaligned.apk
    3. Open CMD in folder with your apk (shift + right click + "Open command window here.")

    Then I use manually jarsigner and then zipalign.exe.

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore key.jks -storepass MYPASSWORD app-release-unaligned.apk 1
    
    zipalign -f -v 4 app-release-unaligned.apk app-release.apk
    

    Then I upload app-release.apk to Google Console. Everything works great ;)