3

I have created a Xamarin Form application using Visual Studio 2017 in Windows 10 and archived the android application to APK file.

When I upload the APK to Google Play console to update my existing app, it says the APK is not signed. Then I used this command to sign the APK using the same certificate

apksigner sign --ks <KEYSTORE_FILE_NAME> --ks-key-alias <ALIAS_NAME> <APK_FILE_NAME>

When I try to upload the signed APK, it says the APK is not zipaligned. Then I used this command to zipalign

zipalign -f -v 4 <OLD_APK_FILE_NAME> <NEW_APK_FILE_NAME>

When I upload the zipaligned APK to console, it says the APK is not signed. After I sign using apksigner it says it is not zipaligned. I am keep on circulating in the same circle again and again.

Even after I zipalign the APK first and then sign, Same error messages are displaying again and again in same circle.

Even if I used jarsigner, the situation is same.

I followed the steps given here

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing/signing-the-app-package/manually-signing-the-apk/

But the APK not getting uploaded. What am I doing wrong?

Please note this is not a duplicate question.

  • 2
    `apksigner` requires you to `zipalign` prior. `jarsigner` requires you to `zipalign` after. These steps are automated by the [Archive Workflow](https://learn.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/index?tabs=windows#archive-for-publishing) in Visual Studio. – Jon Douglas Nov 19 '18 at 21:11
  • @Jon this is the correct answer, can you make it a top level answer instead of a comment? – Pierre Nov 19 '18 at 21:52
  • Feel free to write up your own answer based off of what resolved your problem and accept it. – Jon Douglas Nov 19 '18 at 22:13
  • What is your Android SDK version? over or below v24.0.3? – AbbyWang - MSFT Nov 20 '18 at 05:44
  • @lemontree SDK version 27 –  Nov 21 '18 at 00:26
  • @JonDouglas I tried in both the ways it did not work. Then I have deactivated the app and re-uploaded as new app, it is working but I lost all people installed the old app –  Nov 21 '18 at 00:29

1 Answers1

3

apksigner requires you to zipalign prior to signing. jarsigner requires you to zipalign after signing. This is documented in the zipalign docs.

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37
  • If I use zipalign and then apksigner google play console tells me that apk is not zipaligned. – Adam Dec 10 '20 at 20:34
  • 1
    Like I say in the answer: - either zipalign THEN apksigner, OR - jarsigner THEN zipalign The reverse orders won't work. – Nick Fortescue Dec 14 '20 at 09:44