Skip to main content

Prerequisites

Before you continue, make sure you have:
  • Installed the react-native-moengage package in your project.
  • React Native 0.60 or later. Older versions do not support autolinking and require manual native linking.
  • Android compileSdkVersion 34 or later in android/build.gradle.

Configuring Build Settings

The MoEngage SDK depends on the lifecycle-process library, which in turn depends on androidx.startup:startup-runtime. To keep SDK features working:
  • Do not remove the InitializationProvider component from your AndroidManifest.xml.
  • If you add other initializers that use startup-runtime, also add the initializer for lifecycle-process.
  • See the Lifecycle 2.4.0 release notes for instructions on adding the initializer.

Add AndroidX Libraries

The SDK depends on a few AndroidX libraries for its functioning. Choose one of the following approaches to add them — either enable the flag in package.json (recommended) or add the dependencies directly to your build.gradle file.

Configure in the package.json File

  • Setting includeAndroidXRequiredLibraries to true automatically adds the AndroidX libraries that the SDK uses as dependencies.
  • Required AndroidX libraries: The MoEngage SDK requires the following core AndroidX dependencies:
    • androidx.core:core
    • androidx.appcompat:appcompat
    • androidx.lifecycle:lifecycle-process
  • Before enabling this flag, check whether your application’s native Android project (build.gradle) already includes compatible versions of these libraries. If it does, you may not need to pull them in again, which helps prevent version conflicts or duplicate dependency errors during the build process.
File — package.json

Configure in the Gradle File

Skip this section if you set includeAndroidXRequiredLibraries: true in package.json above. Path — android/app/build.gradle (use build.gradle for Groovy or build.gradle.kts for Kotlin build scripts).
Use the versions shown or higher. Check Google Maven for the latest stable releases.

Verify the Build

After adding the dependencies, run the following command from your project root to confirm that the MoEngage and AndroidX dependencies are resolved correctly:
If the command returns one or more MoEngage entries, the dependencies are linked.

Feature Modules (Optional)

To include optional modules from the MoEngage SDK based on your feature requirements, use the provided flags. By default, these modules are not included in your project. Configure feature modules by adding a moengage key to the root of your project’s package.json file. Set a flag to true to download and link the native dependencies for that module; omit it or set it to false to exclude the module. File — package.json
The following table describes each flag:

Documentation for Optional Feature Flags

The following links cover the Android native SDK. The behavior is equivalent in the React Native SDK.