Integrating Yandex mediation

Warning

Make sure to update your used Yandex mediation adapters and adapters for third-party mediation networks to the latest version. Older versions may cause adapter integration errors that can prevent your ads from being served.

Yandex Mediation is a platform that automatically selects ads from a variety of networks using ML algorithms to maximize your revenue. All settings are turnkey, meaning there's no need to debug each network separately.

If you previously used the Yandex Mobile Ads SDK with only one Yandex network, you won't need to change anything in the code to switch to Yandex mediation. You only need to pre-configure the units in the web interface of external ad networks.

Preliminary setup

To prepare your app, follow the steps from the next sections.

App requirements

  • Use Android Studio 2021 or higher.
  • Use Android Gradle Plugin 7.3.1 or higher.
  • Make sure your app's build file uses the following values:
    • minSdkVersion 21 or later.
    • compileSdkVersion 31 or later.
  • To load ads no matter the type, you need Android 4.1 or later.
  • Video ads are only selected for devices with Android 5 or higher.
  • If you are using the AppMetrica SDK in your application, make sure you have installed the 7th major version (7.x.x).

Set up the application in your Yandex Advertising Network account

Here's how to register your app in the Yandex Advertising Network:

  1. Log in or register your account in the Yandex Advertising Network.
  2. Register your app in the Yandex Advertising Network.

Integration

There are two ways to enable mobile mediation:

  • Unified build (recommended): All available adapters are added automatically.
  • Adding adapters individually: Yandex SDK is installed separately, then specific adapters are added one by one using their respective packages.

You can automatically enable all available adapters using the yandex-mobileads-mediation general mediation package.

  1. Set up mediation in the Yandex Partner interface.

  2. Add the YandexMobileAdsMediation dependency to the build.gradle file in your app's module:

    dependencies {
           ...
           implementation 'com.yandex.android:mobileads-mediation:7.6.0.0'
    }
    

    For each adapter, the latest compatible version is selected automatically.

  3. Add Java 8 support to the build.gradle file in your app's module:

    android {
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
  4. Add the following code to the build.gradle file in your app's module:

    // IronSource
    maven {
           url 'https://android-sdk.is.com/'
    }
    
    // Pangle
    maven {
           url 'https://artifact.bytedance.com/repository/pangle'
    }
    
    // Tapjoy
    maven {
           url "https://sdk.tapjoy.com/"
    }
    
    // Mintegral
    maven {
           url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea"
    }
    
    // Chartboost
    maven {
           url "https://cboost.jfrog.io/artifactory/chartboost-ads/"
    }
    
    // AppNext
    maven {
           url "https://dl.appnext.com/"
    }
    
  5. Set up permission to use the ad ID (optional starting with version 4.5.0).

    How to set up permission to use the ad ID

    The ad ID is a unique identifier provided by Google Play services for displaying ads to users who opt in to personalized ads. Users can opt out of ad personalization or reset their ID in the settings. In this case, advertising networks won't be able to use the ID to select relevant ads for the user.

    If your app runs a Yandex Mobile Ads SDK version below 4.5, add com.google.android.gms.permission.AD_ID to the AndroidManifest.xml file:

    <manifest>
        <application>
        <!-- For apps targeting Android 13 or higher & Yandex Mobile Ads SDK versions lower than 4.5.0 -->
            <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
        </application>
    </manifest>
    

    As of version 4.5.0, the Yandex Mobile Ads SDK adds com.google.android.gms.permission.AD_ID by default. Because of this, you don't have to specify it in the application's main manifest. The permission allows you to use an ad ID to select more relevant ads from advertising networks.

    You can delete the permission if necessary. For example, if a policy does not allow the use of an ID for ad selection, such as the Families Policy.

    To keep the permission from being added to the application's main manifest, add the following code to AndroidManifest.xml:

    <manifest>
        <application>
            <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
        </application>
    </manifest>
    

    Warning

    Lack of this permission and access to the ID may reduce the relevance of ads and, as a result, your income.

  6. Additional setting for the Google AdMob (ex. AdMob) network.

    Add your Google AdMob (ex. AdMob) ID to the AndroidManifest.xml file created for your app using the <meta-data> tag named com.google.android.gms.ads.APPLICATION_ID (here's how to find your AdMob ID).

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

To add individual adapters, enable Yandex Ads SDK and relevant adapters by following the instructions:

  1. Set up mediation in the Yandex Partner interface.

  2. Add the YandexMobileAds dependency to the build.gradle file in your app's module:

    dependencies {
       ...
       implementation 'com.yandex.android:mobileads:x.x.x' // add supported version
    
       // Add dependencies on Yandex mediation adapters.
    
    }
    
  3. Add Java 8 support to the build.gradle file in your app's module:

    android {
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
  4. Add the following code to the build.gradle file in your app's module:

    // IronSource
    maven {
           url 'https://android-sdk.is.com/'
    }
    
    // Pangle
    maven {
           url 'https://artifact.bytedance.com/repository/pangle'
    }
    
    // Tapjoy
    maven {
           url "https://sdk.tapjoy.com/"
    }
    
    // Mintegral
    maven {
           url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea"
    }
    
    // Chartboost
    maven {
           url "https://cboost.jfrog.io/artifactory/chartboost-ads/"
    }
    
    // AppNext
    maven {
           url "https://dl.appnext.com/"
    }
    
  5. Set up permission to use the ad ID (for apps running SDK versions below 4.5.0).

    How to set up permission to use the ad ID

    The ad ID is a unique identifier provided by Google Play services for displaying ads to users who opt in to personalized ads. Users can opt out of ad personalization or reset their ID in the settings. In this case, advertising networks won't be able to use the ID to select relevant ads for the user.

    If your app runs a Yandex Mobile Ads SDK version below 4.5, add com.google.android.gms.permission.AD_ID to the AndroidManifest.xml file:

    <manifest>
        <application>
        <!-- For apps targeting Android 13 or higher & Yandex Mobile Ads SDK versions lower than 4.5.0 -->
            <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
        </application>
    </manifest>
    

    As of version 4.5.0, the Yandex Mobile Ads SDK adds com.google.android.gms.permission.AD_ID by default. Because of this, you don't have to specify it in the application's main manifest. The permission allows you to use an ad ID to select more relevant ads from advertising networks.

    You can delete the permission if necessary. For example, if a policy does not allow the use of an ID for ad selection, such as the Families Policy.

    To keep the permission from being added to the application's main manifest, add the following code to AndroidManifest.xml:

    <manifest>
        <application>
            <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
        </application>
    </manifest>
    

    Warning

    Lack of this permission and access to the ID may reduce the relevance of ads and, as a result, your income.

  6. Add the applicable adapters one by one using the appropriate packages.