How to create Multiple Environments in React Native Android

Hi Guys, In this article, we are going to learn about How to create Multiple Environments in React Native Android. Generally, developers need to create multiple environments for their project to share the build with the Internal testing team or to make App live on the play store. to do this developers need to create productFlavors such as dev for development purposes and prod for the production environment when the developer wants to create signed APK. so in this article we will learn complete Gradle configuration to use App for testing as well as production with signed APK. let’s understand step by step.

1. Create secrets.properties file

Consider you have completed one milestone or one scope of work. and you want to share build with your testing team or you want to share build on open or close testing in the play store. the first step is to create jks file for the project using Android studio. this file is unique and one time so keep it safe in multiple locations in your disk.

To create jks file goto Build-> Generate Signed Bundle

Select Android App Bundle

Click on create new. make sure passwords are noted somewhere or enter the same password for Key store & Alias.

How to create Multiple Environments in React Native Android

Create secrets.properties file in ProjectName/app/secrets.properties

How to create Multiple Environments in React Native Android

Add jks file path & passwords in it.

2. Create multiple environments in gradle

Import secrets.properties file in Gradle as follows

Use secretFile in signingConfigs release section

Finally, add the following flavors code to it.

3. Complete code of Gradle file

After completing these steps you will see two different environments in your project Build Variants section one is for development purposes & the other is for production purposes you can upload prodRelease variant on play store.

If you use same Gradle configuration describe above then you will see four variants:

  1. devDebug  (Use for development)
  2. devRelease  (Use to share with the testing team)
  3. prodDebug  (Use to share with the testing team)
  4. prodRelease  (Use for only production purpose on play store with signed APK)

This is How you can create Multiple Environments in React Native Android.
Thank you 🙂

Leave a Reply

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