Integration Using Version Catalog 11.x.x

In Gradle 7.0, a preview feature Version Catalog was introduced to simplify and share dependencies and versions.
We have published a version catalog to ease out dependency and version management while integrating the various MoEngage SDKs.

When using a version catalog one need not worry about updating multiple versions or maintain compatibility. To update the SDKs simply update the catalog version and everything else will be handled under the hood.

Enable Catalog and Add MoEngage Catalog

 

Since the version catalog feature is in preview it has to be explicitly enabled in the settings.gradle(.kts) file. Once the feature is enabled add the MoEngage catalog to the project as shown below.

settings.gradle.kts

    //enable version catalog feature, required only if you are using gradle version below 7.4
    enableFeaturePreview("VERSION_CATALOGS")
    // adding moengage catalog
    dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
    versionCatalogs {
        create("moengage") {
            from("com.moengage:android-dependency-catalog:1.1.0")
        }
      }
   }
    

 

replace $version with the latest catalog version.

 

Version Catalog feature is made stable in Gradle version 7.4.

Add dependency from the catalog to the application

Once the catalog is added to the project you can add the required SDK dependencies as shown below.

build.gradle.kts

    dependencies {
    // core moengage features
    implementation(moengage.core)
    // optionally add this to use the cards feature
    implementation(moengage.cards)
     // optionally add this to use the geofence feature
    implementation(moengage.geofence)
    // optionally add this to use the Huaewi PushKit feature
    implementation(moengage.pushKit)
    // optionally add this to use the Push Amp Plus feature
    implementation(moengage.pushAmpPlus)
    // optionally add this to use the Inbox UI feature
    implementation(moengage.inboxUi)
    // optionally add this if you are using the core module of Inbox
    implementation(moengage.inboxCore)
    // optionally add this to use the Push Templates feature
    implementation(moengage.richNotification)
   }
    

 

Impact of using Version Catalog

Though a catalog contains meta data of all the SDKs published by MoEngage only the ones added to the application will be bundled in the application and will not have any impact on the apk size.

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