Signing, React Native and the Play Store
To deploy their app to the Play Store, developers have to generate a .keystore file and sign their release with it. The React Native docs do a good job explaining the necessary steps.
To summarize, as of right now (Version 0.70 on macOS) all you have to do is:
- Navigate to your JDK folder by following the output of
/usr/libexec/java_home2. Runsudo keytool -genkey -v -keystore {NAME}.keystore -alias {ALIAS} -keyalg RSA -keysize 2048 -validity 10000(with{NAME}and{ALIAS}replaced, e.gtippinho.keystore) 3. Fill out the prompt 4. Place the generated{NAME}.keystorefile in/android/app5. Add the following to your~/.gradle/gradle.properties(with the correct values):
MYAPP_UPLOAD_STORE_FILE={NAME}.keystore
MYAPP_UPLOAD_KEY_ALIAS={ALIAS}
MYAPP_UPLOAD_STORE_PASSWORD=*****
MYAPP_UPLOAD_KEY_PASSWORD=*****
Again, check out the official docs for up-to-date and more detailed instructions.
So you lost your keystore, what now?
No big deal - as long as you let Google Play manage your signing key. Assuming that, the steps are straightforward. The React Native docs point you to this support article which tells you to go here and follow the instructions.
Those instructions being:
- Generate a new
.jksfile
keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
- Generate a
.pemfile from that.jks
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks *
- Send it to Google via the form
I left the actual commands untouched to point out that Google default to use upload as
an alias (where the React Native Docs default to my-key-alias). This means the .keystore that
you will generate later to sign your app again will need to have that alias, too! So be careful with
what you put here. Always have your aliases match. Keep in mind that the gradle.properties in
~/.gradle/ also references that alias!
What I also learned
- Don't panic! If you have Google Play sign your app you will gain access again (assuming you know your Play login)
- In my experience the support takes less than 24h to reset your key
- Once reset, the new key will become active after an additional 48h
- If you just have the
.permfile you can't do anything - If you just have the
.keystorefile you can't do anything - If you just have the
.jksall you need to do is generate a new.keystorewith the same alias - The initial
.jksfile should be generated from the initialkeytool -genkeycommand - You can't generate a
.jksfrom a.keystore, don't bother - I recommend backing up the
~/.gradle/gradle.propertiesbecause you will lose it at some point - If you haven't already: Checkout Play App Signing