Android SDK AdMob Adapter (v.4.1.1)

Getting Started

This document details the process of integrating YouAppi’s AdMob Adapter with your Android app.

If you have any question you can email us at support@youappi.com

The basic steps of integration are:

  • Add our dependencies to your project.
  • Add YouAppi to your AdMob console.
  • Load an ad.
  • Show an ad.

Requirements:

Minimum API level: 16, Android 4.1

Integration

  • Add the following dependencies to the project build.gradle file inside the repositories section:
    maven { url 'http://repository.youappi.com/repository/snapshot' }
    maven { url 'https://dl.bintray.com/dc289-organization/dc289-mobile' }
    maven { url 'https://maven.google.com' }
    
  • Add to your app build.gradle file the following under dependencies section:
    dependencies {
        implementation 'com.youappi.sdk:youappi-sdk-android:4.1.1.yaga30.june25-SNAPSHOT'
        implementation 'com.google.android.ads.consent:consent-library:1.0.4'
    }

Proguard

If proguard is used, the following entries should be added:

-keep class com.youappi.sdk.mediation.admob.YouAppiInterstitialAd{*;}
-keep class com.youappi.sdk.mediation.admob.YouAppiInterstitialVideo{*;}
-keep class com.youappi.sdk.mediation.admob.YouAppiRewardedVideo{*;}
  • Create a new Android app

    • On ad mob platform go to apps section.
    • Press ADD APP button.

    • Follow through the steps of creating a new app.

    Add ad units to your Android app

    Add new ad units to your app by choosing your app and pressing ADD AD UNIT button

Rewarded Video

  • After pressing ADD AD UNIT button select Rewarded:

  • Fill your ad unit details and press CREATE AD UNIT button:

Interstitial Video and Interstitial Ad

  • After pressing ADD AD UNIT button select Interstitial

  • Fill your ad unit details and press CREATE AD UNIT button:

Create Mediation Group for YouAppi Rewarded Video

  • Choose Mediation tab and press CREATE MEDIATION GROUP button.
  • Fill mediation group details and press CONTINUE:

  • Fill mediation group details and press ADD AD UNITS to connect your mediation group with the rewarded video ad unit.

  • Press DONE to add the ad unit.
  • After the popup is closed and the ad unit is selected, on Ad Sources section press ADD CUSTOM EVENT button.
  • On the popup name your custom event, fill relevant eCPM and press CONTINUE:

  • On the next popup fill the class name of YouAppi rewarded video custom event: com.youappi.sdk.mediation.admob.YouAppiRewardedVideo
  • Fill the Parameter field with a JSON containing information about your access token and ad unit id. For example:
{ "accessToken": "821cfa77-3127-42b5-9e6b-0afcecf77c69", "adUnitId": "testRewardedVideoAdUnit" }
  • Make sure to use your access token and to put ad unit id that contains only letters, numbers or underscores.

  • Press DONE to save the custom event.
  • Press SAVE to create the new mediation group.

Create Mediation Group for YouAppi Interstitial Video and Interstitial Ad

  • Choose Mediation tab and press CREATE MEDIATION GROUP button.
  • Fill mediation group details and press CONTINUE:

  • Fill mediation group details and press ADD AD UNITS to connect your mediation group with the interstitial ad and interstitial video ad units.

  • Press DONE to add the ad unit.
  • After the popup is closed and the ad unit is selected, on Ad Sources section press ADD CUSTOM EVENT button.
  • On the popup name your custom event, fill relevant eCPM and press CONTINUE:

  • On the next popup fill the class name of YouAppi rewarded video custom event:
    • com.youappi.sdk.mediation.admob.YouAppiInterstitialAd
    • com.youappi.sdk.mediation.admob.YouAppiInterstitialVideo
  • Fill the Parameter field with a JSON containing information about your access token and ad unit id. For example:

{ "accessToken": "821cfa77-3127-42b5-9e6b-0afcecf77c69", "adUnitId": "testInterstitialAdUnit" }

  • Make sure to use your access token and to put ad unit id that contains only letters, numbers or underscores.

  • Press DONE to add the ad unit.
  • Press SAVE to create the new mediation group.

Use AdMob SDK to show YouAppi ad units

Init SDK

MobileAds.initialize(this,"<Replace with AdMob Token>");

Rewarded Video

Load

adMobRewardedVideo = MobileAds.getRewardedVideoAdInstance(this);
adMobRewardedVideo.loadAd("<Replace with AdMob Rewarded Video Ad Unit ID>", new AdRequest.Builder().build());

Show

adMobRewardedVideo.show();

Interstitial Video

Load

interstitialVideoAd = new InterstitialAd(this);
interstitialVideoAd.setAdUnitId("<Replace with AdMob Interstitial Video Ad Unit ID>");
interstitialVideoAd.loadAd(new AdRequest.Builder().build());

Show

if (interstitialVideoAd.isLoaded()) {
  interstitialVideoAd.show();
}

Interstitial Ad

Load

interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId("<Replace with AdMob Interstitial Ad Unit ID>");
interstitialAd.loadAd(new AdRequest.Builder().build());

Show

if (interstitialAd.isLoaded()) {
  interstitialAd.show();
}

Load and Show best practices

  • Make sure to init the SDK as soon as the app starts. It might take few seconds to complete the init process.
  • Make sure to load the ad about 30 seconds before you want to show it since it takes time for the ad and assets to be prepared.
  • Make sure to show an ad as close as possible to its load, in order to have a better fill rate and relevant ads.
  • Make sure not to wait too long before showing an ad, since the ad will be expired 5 hours after being called for. In other words, “show” must be performed no more than 5 hours after the “load”.
  • Use ad event listeners in order to be notified when an ad is ready to be shown.
  • Use ad event listeners to handle load and show.
  • Loading an ad too many times without showing it might cause YouAppi servers to block the SDK from requests.