Android SDK AdMob Adapter

534 views 10/05/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:

Download YouAppi’s Android SDK AdMob Adapter

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

Integration

Integrate using AAR files

  • Copy youappi-android-sdk-moat.arr and youappi-sdk-admob.aar files to the apps/libs folder of your project.
  • Add the following to the project build.gradle file inside the repositories section:
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
  • Add to your app build.gradle file the following under dependencies section:
    dependencies {
        implementation name:'youappi-sdk-admob', ext:'aar'
        implementation name:'youappi-android-sdk-moat', ext:'aar'
        implementation 'com.google.code.gson:gson:2.6'
    }

Integrate using repository

  • Add the following to the project build.gradle file inside the repositories section:
    maven { url "http://repository.youappi.com/repository/release" }
    
  • Add to your app build.gradle file the following under dependencies section:
    dependencies {
        implementation "com.youappi.sdk:youappi-sdk-android-admob:4.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 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.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": "tesRewardedVideoAdUnit" }
  • 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": "tesInterstitialAdUnit" }

  • 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();
}

Demo App

A demo app showing a simple usage of the SDK can be found in the following bitbucket repository:

https://bitbucket.org/youappi/youappi-sdk-android-demo-simple

The demo app contains 3 modules:

  • app-demo – Shows how to use YouAppi’s SDK
  • app-demo-admob – Shows how to use YouAppi’s SDK with AdMob adapter
  • app-demo-mopub – Shows how to use YouAppi’s SDK with MoPub adapter

Please make sure to read the README.md file for further instructions.