RewardedVideo Ad of Google Mobile Ads

Rewarded video ad is an advertisement format that displays video ads of approximate from 15 to 30 seconds and gives users items or points in the application.
By using this function, the reward advertisement of Geniee's video will be displayed with the video reward of Google AdMob / Google Ad Manager.

Preparation for implementation

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

  • 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'
       }
       
    2. Update AndroidManifest.xml

      Important: This step is required for Google Mobile Ads SDK version 17.0.0 and above. If you do not add this <meta-data> tag, it will crash and you will see the following message: "The Google Mobile Ads SDK was initialized incorrectly."

      <manifest>
      	<application>
      	<!-- Google AdMob / AdManager -->
      		<meta-data
      		android:name="com.google.android.gms.ads.APPLICATION_ID"
      		android:value="YOUR_APP_ID"/>
      	</application>
      </manifest>
      
      1
      2
      3
      4
      5
      6
      7
      8
  • Geniee SDK

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

  • Geniee mediation adapter

    The following adapter (GNAdGoogleMediationAdapter) needs to be set.

    • 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'
         }
         
    • 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.

        Geniee-Android-SDK

      • Placing the Local Library

        1. Extract Geniee Android SDK.

        2. Add GNAdGoogleMediationAdapter 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 rewarded video

  • AdManager

    By using the UnitID that set mediation on GoogleAdManager management screen, you can display the mediated RewardedVideo ads.
    For details on how to implement the RewardedVideo, please refer to the following site.
    How to implement RewardedVideo of GoogleAdManager

  • AdMob

    By using the UnitID that set mediation on GoogleAdMob management screen, you can display the mediated RewardedVideo ads.
    For details on how to implement the RewardedVideo, please refer to the following site.
    How to implement RewardedVideo of AdMob

※ Implementation notes when using mediation

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

Preparing to use GoogleMobileAds I/F

Import GoogleMobileAds.

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.rewarded.RewardedAd;
import com.google.android.gms.ads.rewarded.RewardedAdCallback;
import com.google.android.gms.ads.rewarded.RewardItem;
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;
1
2
3
4
5

Implement Callback for ad loading / displaying

Implement the RewardedAdLoadCallback method to receive the load notification from the SDK.

private RewardedAdLoadCallback mAdLoadCallback = new RewardedAdLoadCallback() {
    @Override
    public void onRewardedAdLoaded() {
    }

    @Override
    public void onRewardedAdFailedToLoad(int errorCode) {
    }
};
1
2
3
4
5
6
7
8
9

Implement the RewardedAdCallback method to receive the display notification from the SDK.

private RewardedAdCallback mAdCallback = new RewardedAdCallback() {
    public void onRewardedAdOpened() {
    }

    public void onRewardedAdClosed() {
    }

    public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
    }

    public void onRewardedAdFailedToShow(int errorCode) {
    }
};
1
2
3
4
5
6
7
8
9
10
11
12
13

Load rewarded video ad

Implement the ad loading process. We recommend that you perform the loading process in advance. In the load request, specify the UnitID. (Get UnitId from the management screen of Google AdMob / Ad Manager)
If you want to show another video after playing one video, you need to make a load request again.

private RewardedAd mRewardedAd;

private void createAndLoadRewardedAd() {
    mrewardedAd = new RewardedAd(MainActivity.this, "YOUR_UNIT_ID");
    rewardedAd.loadAd(
            new AdRequest.Builder().build(), mAdLoadCallback);
}
1
2
3
4
5
6
7

Display rewarded video

Implement the display process of the advertisement. Please execute the display process after executing Load.

private void showVideoReward() {
    if (mRewardedAd.isLoaded()) {
        mRewardedAd.show(this, mAdCallback);
    }
}
1
2
3
4
5

Give users a reward

To reward video ad viewers, use the callback method onUserEarnedReward.

@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
    Log.d("RewardedAdCallback", "onUserEarnedReward: RewardType = " + rewardItem.getType());
    Log.d("RewardedAdCallback", "onUserEarnedReward: RewardAmount = " + rewardItem.getAmount());
}
1
2
3
4
5

To maximize revenue with video ads, it is important to remunerate video ad viewers.
RewardItem includes the following items.

  • rewardItem.getType():Currency type setting
  • rewardItem.getAmount():Currency amount setting
Last Updated: 3/3/2021, 1:55:59 PM