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

5 Likes

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

Hi,
I’ve tried it, banner is working well, but my interstitial is so laggy, event some times after appearing it stop, and can’t close immediately. And in my admob stat, its requested 500 times but no impression. it’s normal or is some setting that i miss?

Thanks

This means I need to build Unreal from source code and use that for my project, right ?

Hello! can you guys please help me? i m stuck at the copy corresponding aar & pom, also i should delete the old play services ads/ads lite and ads base folders with the old version or just keep them and change from the old version to the new

Hello do you think you can help me figure it out too? if so please hit me up on discord : forgasgafaf123

I think it’s useless for now, because it makes my admob showing less ads , and my ads behave unusual.

Do Youn Know Why When i Try to Add AndroidAdvertising Plugin TO Unreal,As Documentation Said.then the packageing will always failed,

UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:867: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)): ^
UATHelper: Packaging (Android (ASTC)): symbol: method runOnUiThread()
UATHelper: Packaging (Android (ASTC)): location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:892: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)): ^
UATHelper: Packaging (Android (ASTC)): symbol: method runOnUiThread()
UATHelper: Packaging (Android (ASTC)): location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:958: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)): ^
UATHelper: Packaging (Android (ASTC)): symbol: method runOnUiThread()
UATHelper: Packaging (Android (ASTC)): location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:979: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)): ^
UATHelper: Packaging (Android (ASTC)): symbol: method runOnUiThread()
UATHelper: Packaging (Android (ASTC)): location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:999: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)): ^
UATHelper: Packaging (Android (ASTC)): symbol: method runOnUiThread()
UATHelper: Packaging (Android (ASTC)): location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1041: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)): ^
UATHelper: Packaging (Android (ASTC)): symbol: method runOnUiThread()
UATHelper: Packaging (Android (ASTC)): location: variable activityContext of type ContextWrapper
PackagingResults: Error: cannot find symbol
PackagingResults: Error: cannot find symbol
PackagingResults: Error: cannot find symbol
PackagingResults: Error: cannot find symbol
PackagingResults: Error: cannot find symbol
PackagingResults: Error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): Note: Some input files use or override a deprecated API.
UATHelper: Packaging (Android (ASTC)): Note: Recompile with -Xlint:deprecation for details.
UATHelper: Packaging (Android (ASTC)): > Task :app:compileDebugJavaWithJavac FAILED
UATHelper: Packaging (Android (ASTC)): 6 errors
UATHelper: Packaging (Android (ASTC)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (ASTC)): * What went wrong:
UATHelper: Packaging (Android (ASTC)): Execution failed for task ‘:app:compileDebugJavaWithJavac’.
UATHelper: Packaging (Android (ASTC)): > Compilation failed; see the compiler error output for details.
UATHelper: Packaging (Android (ASTC)): * Try:
UATHelper: Packaging (Android (ASTC)): > Run with --stacktrace option to get the stack trace.
UATHelper: Packaging (Android (ASTC)): 62 actionable tasks: 7 executed, 55 up-to-date
UATHelper: Packaging (Android (ASTC)): > Run with --info or --debug option to get more log output.
UATHelper: Packaging (Android (ASTC)): > Run with --scan to get full insights.
UATHelper: Packaging (Android (ASTC)): * Get more help at https://help.gradle.org
UATHelper: Packaging (Android (ASTC)): BUILD FAILED in 22s
UATHelper: Packaging (Android (ASTC)): cmd.exe failed with args /c “G:\Unreal Projects\TestingAd\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug
UATHelper: Packaging (Android (ASTC)): (see G:\UnrealEngine-5.4.1-release\Engine\Programs\AutomationTool\Saved\Logs\Log.txt for full exception trace)
UATHelper: Packaging (Android (ASTC)): AutomationTool executed for 0h 1m 16s
UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: Packaging (Android (ASTC)): BUILD FAILED
PackagingResults: Error: Unknown Error

Any update on this file you linked and the post itself?

I’m using UE4.27.2 Source, and I first did everything that was in the post above, and it didnt work, I tried the 23.2.0 versions first, added the folder etc, then with 22.6.0 and still didnt work (crash on logo after packaging). So I added the file that you provided which is probably from UE5, the file’s length gets to around 479, while what you linked is 532 lines long (so probably they modified it since the release of UE5).

The game crashes with either file and either versions. As soon as the Unreal Engine logo appears it immediately closes in a tenth of a second.

Does this solution still work for anybody? Or is there a better solution?

Can this work for UE4_27_2 ???

I use 4.27.2 too did you get any solution???

not that one, I have used an older version of google play services that was in UE 5.3, then later realised that the UShowExternalLoginUI never ran, now the first time it did, it did show up the google login.

But im not going to use the google leaderboard, its insanely limited, I rather use Firebase for leaderboards