Android 7.x.x

Add mavenCentral() repository in the project-level build.gradle file.

build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
}
allprojects {
    repositories {
        mavenCentral()
    }
}

In android/settings.gradle add the following

Groovy
include ':react-native-moengage'
project(':react-native-moengage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-moengage/android')

In android/app/build.gradle add the following

Groovy
dependencies {
    ...
    implementation project(':react-native-moengage')
    implementation("com.moengage:moe-android-sdk:11.6.02")
    implementation("androidx.core:core:1.3.1")
    implementation("androidx.appcompat:appcompat:1.2.0")
    implementation("androidx.lifecycle:lifecycle-process:2.2.0")
}

Add the MoEngage React Package in the Application class's getPackages()

Java
public class MainApplication extends Application implements ReactApplication {
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(), new MoEReactPackage());
    }
  };
  @Override public void onCreate() {
    super.onCreate();
  }
  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

In case you are facing issues with the import add the below import statement in your java file.

Java
import com.moengage.react.MoEReactPackage;
import com.moengage.core.MoEngage;

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?