Generating a Signed APK in React Native and Publishing it to Play store

Generating a Signed APK in React Native and Publishing it to Play store

When you have completed developing a mobile application using React Native the next thing which you will focus on is Publishing the APK in Google Play Store

Objectives

  • Generating a Debug APK

Generating a Debug APK

We will see how to generate a debug APK in react native version 0.58 and above

  • In your project folder navigate to Android > App > Build > Intermediates

Go to your project directory and open terminal and paste the below command

reactnative bundle platform android dev false entryfile index.js bundleoutput android/app/src/main/assets/index.android.bundle assetsdest android/app/src/main/res

Once done navigate to the Android folder using the below command

ccd android

Run the below command to generate the debug APK

./gradlew assembleDebug (For Linux / Mac)
.gradlew assembleDebug (For Windows)

Once the APK is built navigate to Android > App > Build > Outputs > Apk > Build.

Generating a Signed APK (Release Version)

We will see how to create a signed APK now

Creating a Private Signing Key

For creating a signing key, you can use keytool .

If you are on Windows, keytool can be found at C:\Program Files\Java\jdkx.x.x_x\bin . Open a command prompt with Run as administrator.

Run the following code which generates a keystore valid for 10000 days under the file name my-key.keystore.

Fill the details and enter the password which you have created for the keystore file

Alias is a name that you will use later when signing your app, so remember to take note of the alias.

Don’t ever commit your keystore file to your version control and keep it private and safe

Now you are done with the first step of creating an APK now!

Adding Keystore to your project

Now, you have to place the created Keystore file under the android/appdirectory in your react native project folder

Next, add the following lines to gradle.properties

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

Adding signing config to your app’s Gradle config

android/app/build.gradle

android {
defaultConfig { … }
signingConfigs {
release {
if (project.hasProperty(‘MYAPP_UPLOAD_STORE_FILE’)) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}

Generating the release AAB

cd android
./gradlew bundleRelease

Another post: 

 

 

Check out our categories: Android Update, Elementor, flutter, Guide, Game, Plugin, Theme, webmaster, SEO

Leave a Reply

Your email address will not be published. Required fields are marked *

Total
0
Share