Reputation: 708
I want to update an App on Google Play. I lost the Keystore password, after contacting google support I followed the below-given commands, and they reset the upload key for me.
1. keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
2. keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
Now I have the keystore.jks
file. Now here Problem comes.
I am following these steps in Visual Studio 2019.
Right-click on Myproject.Android > Archive
then getting apk file Bundle Format: apk
Click Distribute > Google Play > Import
then Import an Existing Keystore dialog box it is expecting with an extension of .keystore
file to import but I have .jks
tried to convert it to .keystore
as well but not succeded.
Here is the error I am getting
at Xamarin.AndroidTools.PublicationUtilities.KeyManagement.<>c__DisplayClass13_0.<ImportKeyAsync>b__0(Task`1 t) in C:\A\1\34\s\External\androidtools\Xamarin.AndroidTools\PublicationUtilities\KeyManagement.cs:line 313
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.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 C:\A\1\34\s\src\Core\VisualStudio.Publishing\Presentation\ViewModels\AndroidImportKeyViewModel.cs:line 133
Is there anything I am missing?
How I can use keystore.jks
to update my App?
Upvotes: 1
Views: 2758
Reputation: 1
In case you are using Visual Studio and none of the previous options worked:
I was facing this same error for an hour and I got to this post, it turns out that in my case the Alias Name
was incorrect and generating this error.
(I found out through the .keystore
file name and opening it via notepad) so make sure also that Alias name is correct
Upvotes: 0
Reputation: 11
I had the same issue with one app, and the easiest solution with Visual Studio was:
C:\Users\USERNAME\AppData\Local\Xamarin\Mono for Android\Keystore\alias\alias.keystore
Once you have the new key, use keytool to generate the certificate from that file:
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore alias.keystore
The new certificate (.pem) will be in the same folder, and the .keystore file works just as the .jks that Andoid Studio usually generates but it's better with Visual Studio. This way no realigning is necessary.
Upvotes: 1
Reputation: 21
I ran into the same problem with the Visual Studio keystore import tool and it turns out the import tool requires a non-empty password for the alias as well as the keystore. Here's how you can copy the keystore.jks file to a new upload.keystore file with the alias password required by the import tool:
keytool -importkeystore -srckeystore keystore.jks -srcalias upload -destkeystore upload.keystore -deststoretype pkcs12 -destalias upload -destkeypass password
Now you can use Visual Studio to import the newly created upload.keystore
using the alias password you specified for -destkeypass
above and use Visual Studio to sign as usual rather than signing from the command line.
Upvotes: 2
Reputation: 708
I thought I should post how I resolved this issue if someone else would be facing this issue he might solve it by following these steps.
After getting keystore.jks
file copy your project.Android.apk
and keystore.jks
files to C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.2
location.
run Command Prompt as administrator in given location C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.2
Now you need to zipalign
the apk file manually, run the following commands.
run zipalign -v -p 4 com.project.Android.apk com.projectAligned.Android.apk
then you have to sign apk.
apksigner sign --ks keystore.jks --out com.projectRelease.Android.apk com.projectAligned.Android.apk
Upvotes: 1