Upgrade to Google Play Services Ads v22.6.0 for Android Builds

You might have noticed below warning in Google Play…

com.google.android.gms:play-services-ads-lite has reported play-services-ads-lite:18.1.0 as outdated. You may not be able to release future versions of your app with this SDK version to production or open testing.

I’m on UE 5.3.2, the default available play-services-ads version is 18.1.0.
With above mentioned warning from Google Play, there’s a need to upgrade to one of recent versions like v22.6.0

I’m sharing the details of modifications to upgrade as follows:

  • Add followings in file: …\Engine\Build\Android\Java\aar-imports.txt
com.google.android.gms,play-services-ads,22.6.0
com.google.android.gms,play-services-ads-lite,22.6.0
com.google.android.gms,play-services-ads-base,22.6.0
  • Add following folders at …\Engine\Source\ThirdParty\Android\extras\google\m2repository\com\google\android\gms
  1. play-services-ads\22.6.0
  2. play-services-ads-lite\22.6.0
  3. play-services-ads-base\22.6.0
  1. Open file …\Engine\Source\Runtime\Advertising\Android\AndroidAdvertising\AndroidAdvertising_APL.xml

  2. Add following imports instead of ‘com.google.android.gms.ads.InterstitialAd’

import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.FullScreenContentCallback;
  1. Modify in function AndroidThunkJava_ShowAdBanner() as follows
//Note arg type change
public void onAdFailedToLoad(LoadAdError adError)
  1. Modify in function AndroidThunkJava_LoadInterstitialAd() as follows
//interstitialAd = new InterstitialAd(this);
interstitialAd = null;

//interstitialAd.setAdUnitId(AdMobAdUnitID);
public void run()
{
	//interstitialAd.loadAd(interstitialAdRequest);	
	
	// Create a full screen content callback.
	FullScreenContentCallback fullScreenContentCallback = new FullScreenContentCallback() {
		@Override
		public void onAdDismissedFullScreenContent() {
			interstitialAd = null;
		}
	};

	interstitialAd.load(_activity.getApplicationContext(),
			AdMobAdUnitID,
			interstitialAdRequest,
			new InterstitialAdLoadCallback() {
				@Override
				public void onAdLoaded(InterstitialAd ad) {
					interstitialAd = ad;
					//track if the ad is loaded since we can only called interstitialAd.isLoaded() from the uiThread
					isInterstitialAdLoaded = true;
					isInterstitialAdRequested = false;
					interstitialAd.setFullScreenContentCallback(fullScreenContentCallback);
				}

				@Override
				public void onAdFailedToLoad(LoadAdError adError) {
					// Code to be executed when an ad request fails.
					Log.debug("Interstitial Ad failed to load, errocode: " + adError.getCode());
					isInterstitialAdLoaded = false;
					isInterstitialAdRequested = false;
				}
			}
	);
}
		//Note this listener implementation is disabled
		/*interstitialAd.setAdListener(new AdListener()
		{
			@Override
			public void onAdFailedToLoad(int errorCode) 
			{
				Log.debug("Interstitial Ad failed to load, errocode: " + errorCode);
				isInterstitialAdLoaded = false;
				isInterstitialAdRequested = false;
			}
			@Override
			public void onAdLoaded() 
			{
				//track if the ad is loaded since we can only called interstitialAd.isLoaded() from the uiThread				
				isInterstitialAdLoaded = true;
				isInterstitialAdRequested = false;
			}    
		});*/
  1. Modify in function AndroidThunkJava_ShowInterstitialAd() as follows
public void run()
{
	//Note arg addition
	interstitialAd.show(_activity);
}

Please comment on if you find any bug, mistake or better options…
Hope it helps.

Thank you!
Roxroria Team / Rush At Games

1 Like

If after then you didn’t see Ads, I’ll recommend you use next blueprint code:

or this

AndroidAdvertising_APL.xml (15.2 КБ)

1 Like