Android SDK AdMob Adapter

39 views 22/01/2018 Shay Karpeles 0

Getting Started

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

If you have any question you can email us to: sdk@youappi.com

The basic steps of integration are:

  • Integrate YouAppi SDK using YouAppi SDK integration document.
  • Add YouAppi AdMob mediation AAR file to your project.
  • Follow the instructions below.

Download YouAppi’s Android SDK AdMob Adapter

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

Integration

    • Copy youappiadmob.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 {
          compile(name:'youappiadmob', ext:'aar')
      }
    • Add YouAPPi as a third party custom native network to your AdMob account. Go to Monetize -> <You App Name> -> Ad Units -> NEW AD UNIT. Create an ad unit for each of the YouAPPi ad type you would like to use, for Interstitial card and Interstitial Video select the type “INTERSTITAL”, for RewardedVideo select “REWARDED VIDEO”. Setup you capping options and select the Ad unit name of you liking. Back at the AD UNITS screen, press the “ad sources” under the mediation tab of your selected Ad. Press the “+ NEW AD NETWORK”, in the “New ad networks” screen press “+CUSTOM EVENT”. In the Custom Event Dialog enter the following settings per product:
      • For Interstitial Card enter “com.youappi.ai.admob.YouAPPiInterstitialCard” under class name, choose the Label that you want and leave the Parameter field emtpy.
      • For Interstitial Video enter “com.youappi.ai.admob.YouAPPiInterstitialVideo” under class name, choose the Label that you want and leave the Parameter field emtpy.
      • For Rewarded Video enter “com.youappi.ai.admob.YouAPPiRewardedVideo” under class name, choose the Label that you want and leave the Parameter field emtpy.

      Now you should see the “ad sources” count under the mediation tab for your products have been increased by one.

  • If you use proguard in your application you should add these entries to your proguard file:
    -keep class com.google.gson.**{ *;}
    -keep class com.google.android.gms.**{*;}
    -keep class com.youappi.ai.sdk.**{*;}
    -keep interface com.youappi.ai.sdk.**{*;}
    -keep enum com.youappi.ai.sdk.AdType{*;}
    -keepclassmembers class * {
        @android.webkit.JavascriptInterface <methods>;
    }
     
    -keep class com.youappi.ai.admob.YouAPPiInterstitialCard{*;}
    -keep class com.youappi.ai.admob.YouAPPiInterstitialVideo{*;}
    -keep class com.youappi.ai.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 to your Android app ad units

    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 eCPN and press CONTINUE:

  • On the next popup fill the class name of YouAppi rewarded video custom event: com.youappi.mediation.admob.YouAppiRewardedVideo
  • The custom event classes are found in the SDK zip file in the package named: youappimopub.aar.
  • 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.mediation.admob.YouAppiInterstitialAd
    • com.youappi.mediation.admob.YouAppiInterstitialVideo
  • The custom event classes are found in the SDK zip file in the package named: youappiandroidsdk.aar.

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

Use MoPub SDK to show YouAppi ad units

Init SDKs

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

Rewarded Video

Load

adMobRewardedVideo = MobileAds.getRewardedVideoAdInstance(this);
Bundle rewardedVideoBundle = new Bundle();
rewardedVideoBundle.putString(YouAPPiRewardedVideo.EXTRA_ADUNIT_ID, "rewardedVideoAdUnitId");
adMobRewardedVideo.loadAd("<Replace with AdMob Rewarded Video Ad Unit ID>", new AdRequest.Builder().addNetworkExtrasBundle(YouAPPiRewardedVideo.class, rewardedVideoBundle).build());

Show

adMobRewardedVideo.show();

Interstitial Video

Load

interstitialVideoAd = new InterstitialAd(this);
interstitialVideoAd.setAdUnitId("<Replace with AdMob Interstitial Video Ad Unit ID>");
Bundle videoBundle=new Bundle();
videoBundle.putString(YouAPPiInterstitialVideo.EXTRA_ADUNIT_ID,"interstitialVideoAdUnitId");
interstitialVideoAd.loadAd(new AdRequest.Builder().addCustomEventExtrasBundle(YouAPPiInterstitialVideo.class,videoBundle).build());

Show

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

Interstitial Ad

Load

interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId("<Replace with AdMob Interstitial Ad Unit ID>");
Bundle bundle=new Bundle();
bundle.putString(YouAPPiInterstitialCard.EXTRA_ADUNIT_ID,"interstitialAdUnitId");
interstitialAd.loadAd(new AdRequest.Builder().addCustomEventExtrasBundle(YouAPPiInterstitialCard.class,bundle).build());

Show

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