Android Implementation of AdMob/AdManager video reward mediation(Legacy) (deliver Geniee video reward under AdMob/AdManager)

By using mediation function of AdMob/AdManager, it can distribute video reward of Geniee SDK from AdMob/AdManager.

Preparation for implementation

For Video Reward Advertisement, the following implementation preparation is necessary.

  • Google Play Services SDK To use the Geniee ad SDK, you must install the Google Play Services SDK. The Google Play Services SDK installation procedure is as follows.
  1. Add the following to dependencies ofModule> build.gradle.
dependencies {
    implementation 'com.google.android.gms:play-services-ads:20.0.0'
}
  • If you have already installed the Google Play Services SDK, no addition is required.

  • Geniee SDK

    From the start guide below, you need to install Geniee SDK (GNAdSDK) in the application.
    Start Guide

  • SDK for each add network and adapters

    It is necessary to set the SDK for each ad network and the adapter (GNSRewardAdapter) to distribute using Mediation function of AdMob/AdManager and Geniee SDK.
    To set all the ad networks collectively, please refer to the following link introduction method.
    Bulk Implementation of All Ad Networks

    Also, in order to use the ad network individually, please select the ad network link from the following and refer to the introduction method.

    AD Network Verified version
    maio 1.1.13
    AppLovin 9.14.5
    Unity Ads 3.4.8
    AdColony 4.7.1
    CAReward 2.4.0
    Tapjoy 12.7.0
    Vungle 6.8.0
    Nend 5.4.2
    AMoAd playable-1.0.0
    TikTok 2.0.0.0

Implementation of SDK for AdMob/AdManager Movie Reward Mediation

When implementing with Maven(Recommend)

  1. Add the following to allprojects> repositories inProject> build.gradle.

    allprojects {
    	repositories {
    		// GenieeSDK
    		maven { 
    			url 'https://raw.github.com/geniee-ssp/Geniee-Android-SDK/master/repository' 
    		}
    	}
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
  2. Add the following to dependencies ofModule> build.gradle.

    dependencies {
        implementation 'jp.co.geniee.gnadgooglemediationadapter:GNAdGoogleMediationAdapter:8.5.0.0'
    }
    
    1
    2
    3
    4
  3. Implementation example

  • Project>build.gradle

    allprojects {
    	repositories {
    		jcenter()
    		google()        	
    		// GenieeSDK
    		maven { 
    		    url 'https://raw.github.com/geniee-ssp/Geniee-Android-SDK/master/repository'
    		}
    		// nendSDK
    		maven {
    		    url 'http://fan-adn.github.io/nendSDK-Android-lib/library'
    		}
    		// Maio SDK
    		maven{
    		    url "https://imobile-maio.github.io/maven"
    		}
    		//Adcolony SDK
    		maven {
    		    url  "https://adcolony.bintray.com/AdColony"
    		}
    	}
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
  • Module>build.gradle

    dependencies {	
        implementation fileTree(include: ['*.jar'], dir: 'libs')
    	// Google SDK
    	implementation 'com.android.support:appcompat-v7:26.1.0'
    	implementation 'com.android.support.constraint:constraint-layout:1.1.1'
                implementation 'com.google.android.gms:play-services-ads:20.0.0'
    	// Geniee
    	implementation 'jp.co.geniee.gnadsdk:GNAdSDK:8.5.1' // GenieeSDK
    	implementation 'jp.co.geniee.gnsrewardadapter:GNSRewardAdapter:6.4.1'
    	implementation 'jp.co.geniee.gnadgooglemediationadapter:GNAdGoogleMediationAdapter:8.5.0.0'
    	// Nend
    	implementation 'com.android.support:recyclerview-v7:26.1.0'
    	implementation 'com.android.support:cardview-v7:26.1.0'
    	// Vungle
    	implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

Introduce libraries manually

If it followed the Installing libraries with Maven procedure, you do not need to do this step.

Manual introduction procedure here

Download Geniee Adapter SDK

Download Geniee Android SDK from the following URL.

Placing the Local Library

  1. Extract Geniee Android SDK.

  2. Add GNSRewardAdapter to the project.

  • If the libs folder does not exist, create it as necessary.

  • Copy the following files under the GNAdGoogleMediationAdapter folder to thelibs folder.
    - GNAdGoogleMediationAdapter-8.5.0.0.jar

  • Add to dependencies ofModule / build.gradle.

    dependencies {
    	implementation fileTree(include: ['*.jar'], dir: 'libs')
    }
    
    1
    2
    3

Implementation of AdMob/AdManager video reward advertisement

You can mediate AdMob/AdManager by calling it with the UnitID of the video rewinding mediated in AdMob/AdManager's management screen.
For details on how to implement AdMob/AdManager video reward, please refer to the following site.
https://developers.google.com/mobile-ads-sdk/docs/dfp/android/rewarded-video

※ Implementation notes when using mediation

When creating the reward instantance, specify Activity instead of Context.
If you specify Context, mediation may not work.

Correspondence when the AdMob/AdManager video reward ad becomes No fill

If AdMob/AdManager's video reward fails to load, you can prevent the no fill ads by using Geniee SDK. The implementation steps are as follows.

  1. Import the neccesary classes of Geniee SDK and AdMob SDK.

    import com.google.android.gms.ads.AdError;
    import com.google.android.gms.ads.AdRequest;
    import com.google.android.gms.ads.FullScreenContentCallback;
    import com.google.android.gms.ads.LoadAdError;
    import com.google.android.gms.ads.OnUserEarnedRewardListener;
    import com.google.android.gms.ads.rewarded.RewardItem;
    import com.google.android.gms.ads.rewarded.RewardedAd;
    import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;
    
    import jp.co.geniee.gnadsdk.rewardvideo.GNSRewardVideoAd;
    import jp.co.geniee.gnadsdk.rewardvideo.GNSRewardVideoAdListener;
    import jp.co.geniee.gnadsdk.rewardvideo.GNSVideoRewardData;
    import jp.co.geniee.gnadsdk.rewardvideo.GNSVideoRewardException;
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
  2. Create an instance of GNSRewardVideoAd in Geniee SDK by specifyingZoneID and initialize AdMob RewardedAd

    // Declare AdMob Reward
    private RewardedAd mRewardedAd;
    // Declare Geniee Reward
    private GNSRewardVideoAd mGNReward;
    
    // Geniee GNSRewardVideoAd
    mGNReward = new GNSRewardVideoAd("YOUR_ZONE_ID", MainActivity.this);
    
    // AdMob/AdManager
    AdRequest adRequest = new AdRequest.Builder().build();
    RewardedAd.load(this, "YOUR_AD_UNIT_ID",
            adRequest, new RewardedAdLoadCallback() {
                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    // Handle the error.
                    Log.d(TAG, loadAdError.getMessage());
                    mRewardedAd = null;
    
                    // Geniee SDK Load
                    if (mGNReward != null) {
                        mGNReward.loadRequest(true);
                    }
    
                }
    
                @Override
                public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
                    mRewardedAd = rewardedAd;
                    Log.d(TAG, "Ad was loaded.");
                    mRewardedAd.setFullScreenContentCallback(mFullScreenContentCallback);
                }
            });
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
  3. Implement the Geniee SDK GNAdVideoListener interface.

    mGNReward.setRewardVideoAdListener(new GNSRewardVideoAdListener() {
        @Override
        public void rewardVideoAdDidReceiveAd() {
            Log.i("GNSReward", "Video ad is loading");
        }
    
        @Override
        public void rewardVideoAdDidStartPlaying(GNSVideoRewardData data) {
            Log.i("GNSReward", "Video ad playback start(" + data.adName + ")");
        }
    
        @Override
        public void didRewardUserWithReward(GNSVideoRewardData data) {
            Log.i("GNSReward", "Give users a reward(" +
                    data.adName + " " +
                    data.amount + data.type + ")");
        }
    
        @Override
        public void rewardVideoAdDidClose(GNSVideoRewardData data) {
            Log.i("GNSReward", "Video ad has been closed(" + data.adName + ")");
        }
    
        @Override
        public void didFailToLoadWithError(GNSVideoRewardException e) {
            Log.i("GNSReward", "Video ad load failed.(" + e.getAdnetworkName() +
                    " Code:" + e.getCode() + " " +
                    e.getMessage());
        }
    });
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
  4. Implement the AdMob/AdManager SDK FullScreenContentCallback

    final FullScreenContentCallback mFullScreenContentCallback = new FullScreenContentCallback() {
        @Override
        public void onAdShowedFullScreenContent() {
            // Called when ad is shown.
            Log.d(TAG, "Ad was shown.");
            mRewardedAd = null;
        }
    
        @Override
        public void onAdFailedToShowFullScreenContent(AdError adError) {
            // Called when ad fails to show.
            Log.d(TAG, "Ad failed to show.");
        }
    
        @Override
        public void onAdDismissedFullScreenContent() {
            // Called when ad is dismissed.
            // Don't forget to set the ad reference to null so you
            // don't show the ad a second time.
            Log.d(TAG, "Ad was dismissed.");
        }
    };
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
  5. Implement the loadRequest method of the Geniee SDK RewardVideo on the methodonRewardedVideoAdFailedToLoadwhich is invoked if AdMob/AdManager Load fails.

    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
        // Handle the error.
        Log.d(TAG, loadAdError.getMessage());
        mRewardedAd = null;
    
        // Geniee SDK Load
        if (mGNReward != null) {
            mGNReward.loadRequest(true);
        }
    
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    • If you want to show another RewardVideo after the completion of playback of one RewardVideo, you need to make a load request again.
  6. Check that loadAd / loadRequest is completed in the order of AdMob/AdManager → Geniee SDK and display the RewardVideo by show method.

    	if (mRewardedAd != null) {
    	    Activity activityContext = MainActivity.this;
    	    mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() {
    	        @Override
    	        public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
    	            // Handle the reward.
    	            Log.d(TAG, "The user earned the reward.");
    	            int rewardAmount = rewardItem.getAmount();
    	            String rewardType = rewardItem.getType();
    	        }
    	    });
    	} else if (mGNReward != null && mGNReward.canShow()) {
    	    Log.d(TAG, "The rewarded ad wasn't ready yet.");
    	    mGNReward.show();
    	}
           
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    • Please be sure to execute show after loading AdMob/AdManager.
  7. Grant the user with the Geniee SDK callback method didRewardUserWithReward.

    @Override
    public void didRewardUserWithReward(GNSVideoRewardData data) {
        Log.i("GNSReward", "Give users a reward(" +
                data.adName + " " +
                data.amount + data.type + ")");
    }
    
    1
    2
    3
    4
    5
    6
    • To maximize revenue with Genie's RewardVideo Advertisement it is important to remunerate RewardVideo viewers. The GNSAdReward method contains the following items:

      • reward.type: Set reward type in SSP
      • reward.amount: setting reward amount at SSP
  8. We will link the activity life cycle to the process. This stitching is used to control stop and restart of advertisements.

     @Override
    protected void onStart() {
        super.onStart();
        if (mGNReward != null) {
            mGNReward.onStart();
        }
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        if (mReward != null) {
            mReward.resume(this);
        }
        if (mGNReward != null) {
            mGNReward.onResume();
        }
    }
    
    @Override
    protected void onPause() {
        if (mReward != null) {
            mReward.pause(this);
        }
        if (mGNReward != null) {
            mGNReward.onPause();
        }
        super.onPause();
    }
    
    @Override
    protected void onStop() {
        if (mGNReward != null) {
            mGNReward.onStop();
        }
        super.onStop();
    }
    
    
    @Override
    protected void onDestroy() {
        if (mReward != null) {
            mReward.destroy(this);
        }
        if (mGNReward != null) {
            mGNReward.onDestroy();
        }
        super.onDestroy();
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
  • Also be sure to link AdMob/AdManager life cycle events.
  • When using video rewind for the whole application Please exclude the implementation of mReward.onDestroy (). Implementing mReward.onDestroy () destroys the data in the video reward.
Last Updated: 5/12/2021, 11:34:34 AM