A-Abe
A-Abe

Reputation: 13

What is the keyPassword I am supposed to use for signing a React Native project?

I have made an app project in React Native, and I want to build its apk. I am following the official documentation as shown here https://reactnative.dev/docs/signed-apk-android.

It says that I must first generate a private signing key using keytool. I have followed the instructions for windows. Here is the terminal output:

PS C:\Program Files\Java\jdk1.8.0_271\bin> keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  My Name
What is the name of your organizational unit?
  [Unknown]:  Myself
What is the name of your organization?
  [Unknown]:  OrgName
What is the name of your City or Locality?
  [Unknown]:  CityName
What is the name of your State or Province?
  [Unknown]:  StateName
What is the two-letter country code for this unit?
  [Unknown]:  XY
Is CN=My Name, OU=Myself, O=OrgName, L=CityName, ST=StateName, C=XY correct?
  [no]:  yes

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
        for: CN=My Name, OU=Myself, O=OrgName, L=CityName, ST=StateName, C=XY
[Storing my-upload-key.keystore]
PS C:\Program Files\Java\jdk1.8.0_271\bin>

Immediately after this, the documentation says I must enter the generated keystore password and key password into this file

  1. Place the my-upload-key.keystore file under the android/app directory in your project folder.

  2. Edit the file ~/.gradle/gradle.properties or android/gradle.properties, and add the following (replace ***** with the correct keystore password, alias and key password),

MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=*****
MYAPP_UPLOAD_KEY_PASSWORD=***** 

Later, in android/app/build.gradle, I am to add this:

signingConfigs {
        release {            
            storeFile file(MYAPP_UPLOAD_STORE_FILE)
            storePassword MYAPP_UPLOAD_STORE_PASSWORD
            keyAlias MYAPP_UPLOAD_KEY_ALIAS
            keyPassword MYAPP_UPLOAD_KEY_PASSWORD
        }
    }

I believe the "storePassword" is the "keystore password" which I created earlier when i was prompted by keytool, but I do not remember ever seeing or generating a "keyPassword".

Perhaps this is a banal question, but how do I find my "keyPassword"? Even other tutorial websites seem to assume the user already has it or knows it. Is the "keyPassword" something that I must create right now?

Upvotes: 1

Views: 846

Answers (3)

Rusty
Rusty

Reputation: 4473

If Keytool CLI didn't ask for key password explicitly then it is same as the store password which it asked for.

Upvotes: 0

Damià
Damià

Reputation: 115

You can also create the key using command line:

keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

Then you need to add the key inside android/app folder and add the keystore name inside android/app/build.gradle file, in the signingConfigs configuration.

Upvotes: 1

Tolik Ali
Tolik Ali

Reputation: 61

In Android Studio go Build -> Generate Signed Bundle / Apk. You will see button Create New on second step. There you will be able to create key with password

enter image description here

enter image description here

Upvotes: 0

Related Questions