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
- play-services-ads\22.6.0
- play-services-ads-lite\22.6.0
- play-services-ads-base\22.6.0
-
Copy corresponding *.aar & *.pom files in above newly created folders from maven repo
e.g https://mvnrepository.com/artifact/com.google.android.gms/play-services-ads/22.6.0 -
Modify AndroidAdvertising_APL.xml file as follows (Note: you may need to uncheck read-only from file properties)
-
Open file …\Engine\Source\Runtime\Advertising\Android\AndroidAdvertising\AndroidAdvertising_APL.xml
-
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;
- Modify in function AndroidThunkJava_ShowAdBanner() as follows
//Note arg type change
public void onAdFailedToLoad(LoadAdError adError)
- 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;
}
});*/
- 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