CI/CD in React Native

Varun Singhal
3 min readSep 9, 2023

--

  • Head over to appcenter.ms.
  • Sign up or log in and click on Add new and select Add a new app from the dropdown menu.
  • Enter a name and description for your app.
  • Select the appropriate OS (Android or iOS) and select React Native as the platform.
  • Click on Add new app.

Add the SDK to the project

In a terminal window opened at the root of a React Native project, enter the following line to add Crash and Analytics services to your app:

npm install appcenter appcenter-analytics appcenter-crashes --save-exact

Integrate the SDK

Create a new file with the filename appcenter-config.json in android/app/src/main/assets/ with the following content:

{
"app_secret": "{Your app secret here}"
}

Modify the app’s res/values/strings.xml to include the following lines:

<string name="appCenterCrashes_whenToSendCrashes" moduleConfig="true" translatable="false">DO_NOT_ASK_JAVASCRIPT</string>
<string name="appCenterAnalytics_whenToEnableAnalytics" moduleConfig="true" translatable="false">ALWAYS_SEND</string>

Connect With bitbucket/gitlab/github

There is a minor change you need to make in android/app/build.gradle file. Do not forget to commit the changes to your repo.

... android { ... defaultConfig { ... } ... buildTypes { release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. //signingConfig signingConfigs.release (Comment this line. Uncomment only if you are releasing to playstore.) minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } } ...

After completing generation of Keystore file now Click on Configure

. Now finally click on Save & build

If you get error please set

Open your app center build config page > enable the Environment variables

Set JAVA_HOME as $(JAVA_HOME_11_X64) and click on save and build.

Finally, a build should start and successfully completed. Upon completion of the build, you’ll see something like this.

Then Download Build

Then Distribute App

--

--

Varun Singhal
Varun Singhal

Written by Varun Singhal

React Native/iOS Developer (Mobile App Developer)

No responses yet