Creating the Release Build Apk for Android or React Native

Amit Gupta
2 min readAug 9, 2023

--

Step 1. Generate a keystore

your_key_name can be any name you want to put for your project.

amitgupta@Amits-MacBook-Pro MyApplication > keytool -genkey -v -keystore your_key_name.keystore -alias your_key_name -keyalg RSA -keysize 2048 -validity 10000

Enter keystore password:

Re-enter new password:

What is your first and last name?

[Unknown]: Amit Gupta

What is the name of your organizational unit?

[Unknown]: MS

What is the name of your organization?

[Unknown]: Lists

What is the name of your City or Locality?

[Unknown]: HY

What is the name of your State or Province?

[Unknown]: TL

What is the two-letter country code for this unit?

[Unknown]: IN

Is CN=Amit Gupta, OU=MS, O=Lists, L=HY, ST=TL, C=IN correct?

[no]: yes

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days

for: CN=Amit Gupta, OU=MS, O=Lists, L=HY, ST=TL, C=IN

[Storing android-blank-app.keystore]

Here I use your_key_name as “android-blank-app” shown in output.

Step 2. Adding Keystore to your project

amitgupta@Amits-MacBook-Pro MyApplication > mv android-blank-app.keystore /app

Or You can just move keystore file by drag and drop from your android studio from MyApplication Folder to app folder.

Step3. Add keystore into app/build.gradle

signingConfigs {
release {
storeFile file('android-blank-app.keystore')
storePassword 'password_which_you_entered_during_key_creation'
keyAlias 'android-blank-app'
keyPassword 'password_which_you_entered_during_key_creation'
}
}

buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

If you want to run the Release Build on your Android Studio Project then you can use command like:

> ./gradlew assembleRelease

If It is react Native Project then you can run the following command:

> $ npx react-native bundle — platform android — dev false — entry-file index.js — bundle-output android/app/src/main/assets/index.android.bundle — assets-dest android/app/src/main/res/

> cd android

> ./gradlew assembleRelease

It is complete now . Thanks for reading the content.

--

--