Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing upload key for Android React-Native Application

We had to reset our Android Upload key for a React-Native Android Application. We contacted Google to reset the key.

Google asked us to complete the following steps: Here’s how to generate and register a new upload key:

Follow the instructions in the Android Studio Help Center to generate a new key. It must be different from any previous keys. Alternatively, you can use the following command line to generate a new key:

keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks

This key must be a 2048 bit RSA key and have 25-year validity. Export the certificate for that key to PEM format:

keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks 

Reply to this email and attach the upload_certificate.pem file.

Further Steps
We now have the generated files, keystore.jks and an upload_certificate.pem file.

Previously our application used a '***-release-key.keystore' file to upload.

Build Process
gradle.properties file

MYAPP_RELEASE_STORE_FILE=APPNAME-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=APPNAMEapprelease

build.gradle file

def getPassword(String currentUser, String keyChain) {
  def stdout = new ByteArrayOutputStream()
  def stderr = new ByteArrayOutputStream()
  exec {
      commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w'
      standardOutput = stdout
      errorOutput = stderr
      ignoreExitValue true
  }
  //noinspection GroovyAssignabilityCheck
  stdout.toString().trim()
}

def releasekeypass = getPassword("APPNAME","android_keystore")
def releasekeyalias = getPassword("APPNAME","android_keystore")

Notes
We use fastlane to deploy the application. How do we get/change the .keystore file with the new files we have?

like image 402
StuartM Avatar asked Jun 29 '20 21:06

StuartM


1 Answers

The documentation casually tends to refer to .jks files as .keystore in some places. They are the same format.

Check for yourself:

file APPNAME-release-key.keystore
APPNAME-release-key.keystore : Java KeyStore 
> file keystore.jks
keystore.jks : Java KeyStore 

Then your solution is simple to rename keystore.jks to APPNAME-release-key.keystore.

like image 64
Fabio Avatar answered Sep 30 '22 05:09

Fabio