Unable to Import Existing Keystore

Rob Ward 1 Reputation point

Trying to distrubute/sign the apk and need to reimport my keystore. It doesn't show up anymore, not sure if it disappears because of the windows 11 update or visual studios updates, on 16.11.10. When I try to import it I get "There was an error import the key"

at Xamarin.AndroidTools.PublicationUtilities.KeyManagement.<>c__DisplayClass13_0.<ImportKeyAsync>b__0(Task1 t) in D:\a\_work\1\s\External\androidtools\Xamarin.AndroidTools\PublicationUtilities\KeyManagement.cs:line 313 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.VisualStudio.Publishing.Presentation.ViewModels.AndroidImportKeyViewModel.<Import>d__48.MoveNext() in D:\a_work\1\s\src\Core\VisualStudio.Publishing\Presentation\ViewModels\AndroidImportKeyViewModel.cs:line 133

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,456 Reputation points Microsoft External Staff

    Importing Keystore requires the key password and the keystore password, you could check all the input content is correct, and make sure this keystore file is correct( .jks file or .keystore file? ). You also try to update VS2019 to VS2022 to test. For more information, refer to https://learn.microsoft.com/en-us/xamarin/android/deploy-test/signing/?tabs=windows

  2. Rob Ward 1 Reputation point

    Upgraded to 2022 Enterprise. Got past the import keystore but now it fails when I try to distribute to google play. Get "Sign packages failed, Keystore was tampered with, or password was incorrect." I am pretty sure the password I have is correct, its in a password safe and hasn't changed for 2+ years.

  3. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,456 Reputation points Microsoft External Staff

    Try to delete the bin/obj folder and archive again. You could check the validity of this keystore by keytool. I'm not sure if your password has the symbols: @ ^ ] $, you could refer to this thread: https://github.com/xamarin/xamarin-android/issues/4036

Answer recommended by moderator

Rob Ward 1 Reputation point

Existing keystore doesn't seem to like my password. Ended up having to go back to an old jks keyfile that was converted years ago, it had a password with an @ symbol in it so changed the password on it and renamed the file to .keystore and it finally worked. Thanks for pointing me in the right direction.

  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,456 Reputation points Microsoft External Staff

    You are welcome. Would you mind converting it to an answer so that someone who has the same issue could refer to it?

1 additional answer

  1. Anton Modaresi 1 Reputation point

    I couldn't get visual studio to import the keystore. But just moving the keystore files (keyinfo and keystore) worked. The files are in C:\Users<username>\AppData\Local\Xamarin\Mono for Android\Keystore<keyname>

    1. Anton Modaresi 1 Reputation point

      I think one of the reasons I had a hard time exporting was that the alias was not matching what I had in my notes. You can use the keytool to look into the keystore and see the alias name.