Skip to main content

Import and Initialize SDK

Before you start

Meson supports Android version 4.4 (API Level 19) and above.

The download and use of the SDK is subject to the Meson SDK Licensing Terms. If you do not agree to these terms, do not download, access, or use the SDK, or the underlying services.

Add Meson SDK to the project#

Meson supports both Gradle dependencies and manual download mechanisms to integrate our SDK.

Add the following to your app's build.gradle file inside repositories section:

allprojects {
repositories {
. . .

On successful sync, you’ll be able to add any Android dependency hosted on mavenCentral repository to build.gradle

Add the following to the dependencies section of build.gradle:

implementation 'ai.meson.sdk:meson:1.0.0-beta7'
implementation 'ai.meson.sdk:meson-core:1.0.1-beta4'

Add Mediated SDK and Adaptor#

To add the mediated SDK adaptor and SDK with Gradle, select the networks and add the following dependencies to the build.gradle.

See the list of supported networks and integration guides here.

Facebook Audience Network
Real-time CPM
Real-time CPM
Real-time CPM
Real-time CPM
Predicted CPM
Predicted CPM
Fixed CPM
Google AdMob
Fixed CPM
Google Ad Manager
Fixed CPM
Real-time CPM

Add Additional Dependencies#

Add additional dependencies like Play Services, to allow GAID information to be retrieved, to your build.gradle.

implementation ''

Add Kotlin Dependencies#

Add the Kotlin dependencies to your build.gradle, if you are NOT using Kotlin for development

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"

Add ProGuard Rules#

If you are using ProGuard, you must add the following code to your ProGuard file

  • If using Android Studio:
  • If using Eclipse: proguard-project.txt
-keep class ai.meson.** {*;}
-keep interface ai.meson.** {*;}
-keepclassmembers class ai.meson.** { public *; }

Initialize the SDK#

Initialize the SDK by calling Meson.initialize(mesonSdkConfiguration, listener) method. The SDK must be initialized successfully before carrying out any other operations.

During initialization, the SDK will:

  • Fetch the mobile app configurations from the server
  • Set the GDPR consent settings for the given app
  • Initialize mediated SDKs

Initialize the SDK once per app lifecycle using the MesonSdkConfiguration object. The listener object is optional.

/*Meson SDK Configuration Object*/
val gdprConsent = JSONObject().run {
put(MesonSdk.MES_GDPR_CONSENT_AVAILABLE, true) //consent value that is obtained from User
put(MesonSdk.MES_GDPR_CONSENT_GDPR_APPLIES, "0") //0 if GDPR is not applicable and 1 if applicable
put(MesonSdk.MES_GDPR_CONSENT_IAB, "<IAB String v1 or v2>")//user consent in IAB format
val mesonSdkConfiguration = MesonSdkConfiguration.Builder(this, "<MESON_APP_ID>").setConsent(gdprConsent).build()
/*Initialize Meson SDK*/
MesonSdk.initialize(mesonSdkConfiguration, object: MesonSdkInitializationListener {
override fun onComplete(error: Error?) {
if(error == null) {
} else {
//continue with publisher integration

Add User Data#

This is optional. In case you want to send us any information about the user, please do as follows:

To set user data, follow:

//Set Extras
val ppidObject = JSONObject().run {
put("PPID", "3f4364a6-cc98-4cbf-8b67-7aec972833ff")
val gpidobject = JSONObject().run {
put("GPID", "67580000-8cf0-11bd-b23e-10b96e40000d")
val extras = JSONObject() {
put("age", 18)
put("gender", BaseMesonInit.GENDER.MALE)
put("segments", JSONArray(listOf("s1", "s2", "s3")))
put("experiments", JSONArray(listOf("e1", "e2", "e3")))
put("customIds", JSONArray(listOf(ppidObject, gpidObject)))
//Set Location
val location = Location(LocationManager.GPS_PROVIDER);

To get or reset user data, follow:

MesonSdk.getExtras() //gets the extra values set in SetExtras
MesonSdk.getSDKVersion() //gets the SDK version
//Clears extras, location

Configure Logging#

When logging is set to DEBUG, SDK will print key logs to the DDMS console that provide useful information about the initialization and bid request lifecycle.