Prerequisites
Before you continue, make sure you have:- Installed the
react-native-moengagepackage in your project. - React Native
0.60or later. Older versions do not support autolinking and require manual native linking. - Android
compileSdkVersion34or later inandroid/build.gradle.
Configuring Build Settings
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 inpackage.json (recommended) or add the dependencies directly to your build.gradle file.
Configure in the package.json File
- Setting
includeAndroidXRequiredLibrariestotrueautomatically adds the AndroidX libraries that the SDK uses as dependencies. - Required AndroidX libraries: The MoEngage SDK requires the following core AndroidX dependencies:
androidx.core:coreandroidx.appcompat:appcompatandroidx.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.
package.json
Configure in the Gradle File
Skip this section if you setincludeAndroidXRequiredLibraries: 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: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 amoengage 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
Documentation for Optional Feature Flags
The following links cover the Android native SDK. The behavior is equivalent in the React Native SDK.