Skip to main content

Configuring Build Settings

Add Androidx Libraries

The MoEngage SDK depends on the lifecycle-process library for a few key features to work, and the latest version of lifecycle-process depends on the androidx.startup:startup-runtime library. Hence, do not remove the InitializationProvider component from the manifest. When adding other Initializers using the startup-runtime, make sure the Initializer for the lifecycle-process library is also added. Refer to the documentation to know how to add the Initializer
The SDK also depends on a few Androidx libraries for its functioning. Add the below Androidx libraries in your application’s build.gradle file or enable the required flag in the Package JSON file.

Configure in the Package JSON file

  • Setting the includeAndroidXRequiredLibraries to true automatically adds the AndroidX libraries that are used by the SDK as a dependency.
  • 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, validate if your application’s native Android project (build.gradle) already has compatible versions of these libraries installed. If your app already includes them, 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
{
    "moengage": {
        "includeAndroidXRequiredLibraries": true
    }
}

Configure in the Gradle file

Skip this step if includeAndroidXRequiredLibrariesflag is enabled in previous step. Path - android/app/build.gradle(.kts)

    dependencies {
    ...
      implementation("androidx.core:core:1.9.0")
      implementation("androidx.appcompat:appcompat:1.4.2")
      implementation("androidx.lifecycle:lifecycle-process:2.7.0")
    }

Feature Modules (optional)

To include optional modules from the MoEngage SDK based on your feature requirements, you can use the provided flags. By default, these modules are not included in your project. You can configure this by adding a new “moengage” key to the root level of your project’s package.json file. Inside this object, you can pass specific feature flags:
  • true: Instructs the build system to download and link the required native dependencies for that specific module.
  • false (or omitting the key): Excludes the module from your project. By default, all optional modules are excluded to help keep your overall app size optimized.
File - package.json
{
    "moengage": {
        "richNotification": true,
        //Required for Push Templates
       
        "encryption": true,
       //Required for Add-On-Security
      
        "pushAmp": true,
        //Required for Push Amplification
      
        "hmsPushkit": true,
        //Required for HMS PushKit
      
        "deviceTrigger": true
       //Required for Device Triggered
    }
}

Documentation For Optional Feature Flag