Android SDK MoPub Adapter V.4.3.10

Getting Started

This document details the process of integrating YouAppi Android MoPub adapter with your Android app.

If you have any questions, please, feel free to email us: support@youappi.com

The basic steps of integration are:

Download YouAppi’s Android SDK MoPub Adapter

Android MoPub adapter can be found in YouAppi Android SDK package as youappi-sdk-android-mopub.aar

Integration

Integrate using AAR files

  • Copy youappi-sdk-android-moat-yg.aar and youappi-sdk-android-mopub.aar file to the apps/libs folder of your project.
  • Add the following to your project build.gradle file inside the repositories section:
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
  • Add the following under dependencies section of app’s build.gradle (replace the ‘x.xx’ version field with the latest available version of the SDK):
    dependencies {
        implementation name:'youappi-sdk-android-mopub', ext:'aar'
        implementation name:'youappi-sdk-android-moat-yg', ext:'aar'
    }

Integrate using repository

  • Add the following repository to your project build.gradle:
repositories {
    maven { url "http://nexus-ext.youappi.com/repository/release-ext" }
}
  • Add the following dependency to your module build.gradle:
dependencies {
    implementation 'com.youappi.sdk:youappi-sdk-android-mopub-moat-yg:4.3.10'
}

Proguard

If you use proguard in your application you should add these entries to your proguard file:

-keep class com.youappi.sdk.mediation.mopub.YouAPPiInterstitialAd{*;}
-keep class com.youappi.sdk.mediation.mopub.YouAPPiInterstitialVideo{*;}
-keep class com.youappi.sdk.mediation.mopub.YouAPPiRewardedVideo{*;}

Create YouAppi custom network

  • On MoPub platform on Networks tab, add a new custom network for YouAppi:
  • On the popup that opens choose to add a Custom Native Network.
  • Name your new network (YouAppi might be a good name) and fill other relevant details.

Setup MoPub for YouAppi Ad units

Create rewarded video ad anit

  • On your MoPub account, press Apps tab.
  • Select your Android app for which you would like or create the new ad unit or create a new Android app.On your app screen press “New ad unit” button:

  • On your app screen press “New ad unit” button:

  • Name your add unit, select Format: Rewarded Video and press Save

Create Interstitial Video or Interstitial Ad units

  • Assuming you already created an Android app, press Apps tab and from the apps list choose your Android app.
  • Press New ad unit button to define a new ad unit for either Interstitial Video or Interstitial Ad.
  • Name you ad unit, choose relevant device and on format choose Fullscreen:

Setup Ad Unit on network

  • Choose Networks and select your YouAppi custom network.
  • On network details screen choose Edit Network.
  • On Set Up Your Inventory section, connect between your Android app ad unit and YouAppi by setting the proper Custom Event Class.
  • For each ad unit type there is a different custom event class:
    • Rewarded Video: com.youappi.sdk.mediation.mopub.YouAppiRewardedVideo
    • Interstitial Video: com.youappi.sdk.mediation.mopub.YouAppiInterstitialVideo
    • Interstitial Ad: com.youappi.sdk.mediation.mopub.YouAppiInterstitialAd
  • On the custom event class data the following information should be supplied:
    • accessToken – the access token of the partner received from YouAppi.
    • adUnitId – an arbitrary id chosen the by app developer to identify the ad unit id. It should be by only numbers, letters and underscores.
  • Here is an example of how the custom event class data should look like:
    {
      "accessToken": "821cfa77-3127-42b5-9e6b-0afcecf77c67",
      "adUnitId": "testRewardedVideoAdUnitId"
    }

Enable YouAppi ad unit to run on YouAppi custom network

  • Press Segments tab and choose your desired segment.
  • Under your Android app find your desired ad unit and YouAppi custom network.
  • Switch your network to running by pressing the button under Enabled column:

Use MoPub SDK to show YouAppi ad units

Rewarded Video

Load

SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder("<Replace with MoPub Rewarded Video Ad Unit ID>").build();
MoPub.initializeSdk(this, sdkConfiguration, this);
MoPubRewardedVideos.loadRewardedVideo("<Replace with MoPub Rewarded Video Ad Unit ID>");

Show

MoPubRewardedVideos.showRewardedVideo("<Replace with MoPub Rewarded Video Ad Unit ID>");

Interstitial Video

Load

MoPubInterstitial moPubInterstitialVideo = new MoPubInterstitial(this, "<Replace with MoPub Interstitial Video Ad Unit ID>");
moPubInterstitialVideo.load();

Show

moPubInterstitialVideo.show();

Interstitial Ad

Load

MoPubInterstitial moPubInterstitialAd = new MoPubInterstitial(this, "<Replace with MoPub Interstitial Ad Unit ID>");
moPubInterstitialAd.load();

 Show

moPubInterstitial.show();