In this tutorial, we’ll show you how to update old AdMob script in Unity to ensure compatibility with the latest AdMob SDK, Unity versions, and platform requirements. Google regularly updates its APIs, and failing to adapt your codebase may lead to broken ads, revenue loss, or even app rejection during store submissions. If you’re working on a Unity project that uses Google AdMob for monetization, it’s important to keep your implementation up to date.
Whether you’re facing deprecated methods, plugin conflicts, or build errors after updating your Unity version, this guide will help you identify, update, and future-proof your AdMob integration.
Why You Should Update Your AdMob Integration
Before diving into the steps, let’s understand why updating your AdMob implementation is critical:
-
Avoid Deprecated APIs: Google often retires old functions or changes naming conventions.
-
Ensure SDK Compatibility: AdMob SDK updates fix bugs, improve performance, and support newer Android/iOS versions.
-
Pass Store Requirements: App stores frequently change policies around privacy, tracking, and monetization.
-
Improve Stability: Updates often fix crashes, ANRs (Application Not Responding), and ad loading issues.
-
Use New Ad Formats: New versions of AdMob may support updated or enhanced ad types and reporting metrics.
So, if your ads have stopped working, or you see console warnings and errors related to AdMob, it’s time to update.
Unity Update AdMob Script – Step-by-Step
If you’re searching Unity update AdMob script, you’re likely dealing with a legacy implementation that no longer works with the current SDK. Here’s a step-by-step guide to modernize your AdMob integration.
Step 1: Remove Old AdMob Files
Before updating, clean up the old files to prevent conflicts.
-
Open your Unity project.
-
Navigate to the Assets/Plugins/Android, Assets/Plugins/iOS, and Assets/GoogleMobileAds directories.
-
Delete any folders/files related to previous AdMob SDKs.
You can also search your project for old class names like InterstitialAd, BannerView, or RewardBasedVideoAd and take note of their usage.
Step 2: Download the Latest AdMob Unity Plugin
To proceed with the update Unity AdMob scripting API, you’ll need the newest version of the plugin.
-
Go to the official GitHub page: https://github.com/googleads/googleads-mobile-unity/releases
-
Download the latest .unitypackage file.
-
Import it into your project:
-
Unity Menu → Assets → Import Package → Custom Package…
-
Select the downloaded .unitypackage
-
Import all files when prompted
-
This plugin includes updated classes, scripts, and native libraries for Android and iOS.
Step 3: Initialize the Mobile Ads SDK
Google now recommends initializing the SDK at runtime before loading ads.
Replace your old initialization code (if any) with:
using GoogleMobileAds.Api;
void Start()
{
MobileAds.Initialize(initStatus => {
Debug.Log("AdMob initialized");
});
}
Place this in a singleton manager or a bootstrap script that runs at app launch.
Update Unity AdMob Scripting API Usage
Once the new plugin is imported, you need to refactor your existing ad logic. This is crucial if you want to update Unity AdMob scripting API without breaking your app.
Banners
Old Code:
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
bannerView.LoadAd(new AdRequest.Builder().Build());
Updated Code (same but ensure correct namespace and placement):
using GoogleMobileAds.Api;
BannerView bannerView;
public void CreateBannerView()
{
Debug.Log("Creating banner view");
// If we already have a banner, destroy the old one.
if (_bannerView != null)
{
DestroyAd();
}
// Create a 320x50 banner at top of the screen
_bannerView = new BannerView(bannerID, AdSize.SmartBanner, AdPosition.Top);
LoadAd();
}
public void LoadAd()
{
// create an instance of a banner view first.
if (_bannerView == null)
{
CreateBannerView();
}
// create our request used to load the ad.
var adRequest = new AdRequest();
// send the request to load the ad.
Debug.Log("Loading banner ad.");
_bannerView.LoadAd(adRequest);
}
No major changes for banners, but ensure you’re using the correct GoogleMobileAds.Api namespace and the latest plugin methods.
Interstitial Ads
Old Code:
InterstitialAd interstitial;
interstitial = new InterstitialAd(adUnitId);
interstitial.LoadAd(new AdRequest.Builder().Build());
Updated Code:
private InterstitialAd _interstitialAd;
public void LoadInterstitialAd()
{
// Clean up the old ad before loading a new one.
if (_interstitialAd != null)
{
_interstitialAd.Destroy();
_interstitialAd = null;
}
Debug.Log("Loading the interstitial ad.");
// create our request used to load the ad.
var adRequest = new AdRequest();
// send the request to load the ad.
InterstitialAd.Load(interstitialID, adRequest,
(InterstitialAd ad, LoadAdError error) =>
{
// if error is not null, the load request failed.
if (error != null || ad == null)
{
Debug.LogError("interstitial ad failed to load an ad " +
"with error : " + error);
return;
}
Debug.Log("Interstitial ad loaded with response : "
+ ad.GetResponseInfo());
_interstitialAd = ad;
RegisterEventHandlers(_interstitialAd);
});
}
Event handler wiring is crucial, especially if you’re tracking ad performance or loading logic.
Rewarded Ads
Old (Deprecated) Code:
RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
Updated Code:
public void LoadRewardedAd()
{
// Clean up the old ad before loading a new one.
if (_rewardedAd != null)
{
_rewardedAd.Destroy();
_rewardedAd = null;
}
Debug.Log("Loading the rewarded ad.");
// create our request used to load the ad.
var adRequest = new AdRequest();
// send the request to load the ad.
RewardedAd.Load(rewardedID, adRequest,
(RewardedAd ad, LoadAdError error) =>
{
// if error is not null, the load request failed.
if (error != null || ad == null)
{
Debug.LogError("Rewarded ad failed to load an ad " +
"with error : " + error);
return;
}
Debug.Log("Rewarded ad loaded with response : "
+ ad.GetResponseInfo());
_rewardedAd = ad;
RegisterEventHandlers(_rewardedAd);
});
}
This is a major change— RewardBasedVideoAd is deprecated and replaced by RewardedAd.
Update Unity AdMob Plugin (for Android & iOS)
Now that the scripts are updated, let’s walk through how to update Unity AdMob plugin for both mobile platforms.
Android
-
Gradle Build System: Unity uses a Gradle-based build system. Ensure your mainTemplate.gradle includes required dependencies.
-
AndroidManifest.xml:
-
Include AdMob permissions and services.
-
Unity now supports custom Android manifests (Plugins/Android/AndroidManifest.xml).
-
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
-
ProGuard Rules (if using ProGuard):
Add these to your ProGuard file:
-keep public class com.google.android.gms.ads.** { *; }
-keep class com.google.ads.** { *; }
iOS
-
Ensure the iOS build platform is set correctly in Unity.
-
After building, open the Xcode project and:
-
Link required frameworks: AdSupport.framework, StoreKit.framework, etc.
-
Add your AdMob App ID to Info.plist:
-
-
Update your CocoaPods dependencies if necessary:
-
Run pod install in the exported iOS project directory.
-
Testing Your Updated Integration
After making updates to scripts and plugins:
-
Use Test Ads to prevent policy violations.
-
Replace your ad unit ID with Google’s test IDs:
-
-
Test on Real Devices – Emulators can behave differently than actual hardware.
-
Check Console Logs for SDK initialization, ad load status, and error messages.
-
Verify Platform-Specific Modules – Test both Android and iOS if you support both platforms.
Common Errors and Fixes After Updating
Here are some issues developers often encounter after trying to update old AdMob scripts:
1. “RewardBasedVideoAd is Obsolete”
Fix: Replace with RewardedAd and update related event handlers.
2. “AdFailedToLoad” or “AdNotReady”
Fix:
-
Ensure MobileAds.Initialize() has completed before calling LoadAd().
-
Use test ads for initial development.
-
Check internet connection.
3. Missing GoogleMobileAds Namespace
Fix:
-
Make sure the latest plugin was properly imported.
-
Verify you don’t have namespace conflicts in your scripts.
4. Android Build Fails Due to Missing Gradle Dependencies
Fix:
-
Use External Dependency Manager (EDM) to resolve libraries.
-
From Unity: Assets > External Dependency Manager > Android Resolver > Force Resolve.
Conclusion
Updating legacy code can be intimidating, but knowing how to update old AdMob script in Unity ensures your ads stay functional, performant, and compliant with the latest standards. Google’s Mobile Ads SDK evolves frequently, and keeping your integration up to date is key to maximizing ad revenue and minimizing bugs.
If you’re planning to scale or launch new features, regularly update Unity AdMob scripting API and monitor release notes from Google. This keeps you ahead of deprecations, platform changes, and app store policy shifts.
Also, make it a habit to update Unity AdMob plugin during major OS upgrades to prevent crashes and broken ad logic. A clean and updated AdMob implementation helps maintain monetization flow and boosts app quality overall.
With this guide, you’re now equipped to update your Unity AdMob scripts with confidence—ensuring your monetization strategy remains strong and future-proof.
Check Integration Guide From Here
Download Google Mobile Ads Plugin From Here
Once you’ve updated your old AdMob script, it’s a good idea to test everything with a simple ad format to ensure the integration is working correctly. If you’re not sure where to start, our Unity AdMob Banner Ads Tutorial provides a clear walkthrough for setting up banner ads in your project, making it easier to verify that your updated script functions as expected.