Losing your keystore file can be a nightmare for any mobile developer. That's exactly what happened to me when I deleted my React Native project from my Mac and cloned it back from GitHub. To my horror, the my-upload-key.keystore
file, which I used to sign and publish my app on the play store, was missing. I tried generating a new one, but the play store rejected it, saying it didn't match the previous build key. I was stuck and didn't know what to do next.
I had a few options to consider, but I couldn't create a new .keystore
file as that would take too much time and I didn't have a backup 🤦♂️. My last option was to find a way to restore my .keystore
file. After a lot of searching and grinding, I discovered that I had been keeping a .jks
file somewhere in my mac 😅, and I found out that it could be used to restore the .keystore
file.
Converting a .jks
file to .keystore
is a straightforward process that can be done using the keytool
command in the terminal or command line. First, navigate to the folder where the .jks
file is located using the cd
command. Then, run the keytool command with the necessary arguments to convert the .jks
file to a .keystore
file.
keytool -importkeystore -srckeystore upload-keystore.jks -destkeystore my-upload-key.keystore -srcstoretype JKS -deststoretype PKCS12
Note that, in this command, you need to replace "upload-keystore.jks" with the name of your .jks
file, and "my-upload-key.keystore" with the desired name of your new .keystore file
. The command will prompt you to enter the password for the .jks
file, and then it will generate the new .keystore
file. If you don't know the password and the name you can view it from your android/gradle.properties
file. This is because when you first set up your React Native project you must have generated it. It will look something like this:
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=*****
MYAPP_UPLOAD_KEY_PASSWORD=*****
After generating the new .keystore
file, I was able to successfully build my app and publish it on the Google Play Store 🎉.
In conclusion, if you ever face a similar situation, don't panic. Instead, check if you have any .jks
files that could be used to restore your .keystore
file. This simple solution saved me a lot of time and hassle, and I hope it helps you too!
Top comments (2)
mate thank you for writing this post. I did exactly the same thing and you've probably saved me hours of pain!
I am glad it was useful 👍