Skip to content

3 - Add X3M SDK and MetaMediation adapters to your app

X3M's Maven repository

In the project level gradle configuration file, include X3M's Maven repository:

allprojects {
    buildscript {
        // [...]
    }

    repositories {
        // [...]

        maven { url "https://android-artifact-registry.x3mads.com/maven" }
    }
}
allprojects {
    buildscript {
        // [...]
    }

    repositories {
        // [...]

        maven {
            url = URI("https://android-artifact-registry.x3mads.com/maven")
        }
    }
}

XMediator Core dependency

In the app-level gradle configuration file, add the following dependency:

dependencies {
    implementation 'com.x3mads.android.xmediator:core:+'
}
dependencies {
    implementation("com.x3mads.android.xmediator:core:+")
}

Add your Google Ads App Id to the Android Manifest

XMediator utilizes Google Ads services to obtain the GAID (Google Advertising ID) required by some mediation networks to serve ads.

In your app's manifest add the following metadata with your own Google Ads App ID obtained in the previus step:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>
        <!-- [...] -->

        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />

    </application>
</manifest>

Choose Mediators and Networks

Use the following tool generate compatible dependencies for the Networks and Mediation SDKs of your choice:

Warning

If you are using AppLovin/MAX adapter v12.4.0 or newer through LevelPlay mediation, please be sure to remove any entry for applovin.sdk.key from your AndroidManifest.xml to avoid any compatibility issues with AppLovin's new initialization API. For more information, please visit AppLovin's documentation.

Initialize the SDK

Before requesting any ad, make sure to call XMediatorAds.startWith(). This method configures your application Key, and fetches the required configuration parameters for the ad placements in your app, among other things.

Additionally, you may want to wait for the initialization callback to complete. This will ensure that your placement requests have the necessary prebid configurations. In addition to the example below, you can see a real implementation in our Android Demo App.

XMediatorAds.startWith(
    activity = activity,
    appKey = "<your-app-key>",
    initSettings = InitSettings(
        userProperties = UserProperties(
            userId = "<your-user-id>",
        ),
    ),
    initCallback = {
        Log.d("X3M", "Initialization complete!")
    },
)
XMediatorAds.startWith(
    activity,
    "<your-app-key>",
    new InitSettings.Builder()
            .setUserProperties(new UserProperties("<your-user-id>", new CustomProperties.Builder().build()))
            .build(),
    initResult -> {
        Log.d("X3M", "Initialization complete!")
        return Unit.INSTANCE;
    }
);

Warning

To ensure the SDK is correctly configured before ad mediation begins, any method that performs an ad request will raise an exception if they are called before XMediatorAds.startWith() is invoked.

It is mandatory to wait for the init callback to complete before making any ad request.