Tag Archives: mobile_ads_sdk

Join our “Google Advertising and Measurement Community” Discord Server

We’re launching our new “Google Advertising and Measurement Community” Discord server! To join, just click this invite link and follow the onboarding guide.

The current products available on this server are Analytics, Google Ads, Google AdMob, and Google Ad Manager.

The Ads Developer Relations team will be on this server regularly to discuss your feedback or questions using Google’s Advertising and Analytics APIs/SDKs, as well as to let you know what’s new with our products.

We’ll be hosting a “Meet the Team” in August, where we’ll go over who we are, and how you can expect to engage with us in Discord. Stay tuned as we add other events, and more channels.

Looking forward to chatting with you on Discord!

Announcing Android Google Mobile Ads SDK version 24.0.0

Version 24.0.0 of the Android Google Mobile Ads SDK is now available. To take advantage of the latest features and performance improvements, we highly recommend you configure your app to upgrade as soon as possible. Major changes to the SDK are as follows:

Minimum Android API level

Starting with version 24.0.0, the Google Mobile Ads SDK requires all apps to be on a minimum Android API level of 23. To adjust the API level, change the value of minSdk in your app-level build.gradle file to 23 or higher.

Optimized initialization and ad loading

By default, The OPTIMIZE_INITIALIZATION and OPTIMIZE_AD_LOADING flags are now generally available and set to true. These flags help reduce ANRs. You can further prevent ANRs by initializing the Google Mobile Ads SDK on a background thread. For more information, see Optimize initialization and ad loading.

Removed ad services config in AndroidManifest.xml

To prevent merge conflicts for apps that configure API-specific Ad Services, we've removed the android.adservices.AD_SERVICES_CONFIG property tag from the SDK’s manifest file. This change provides greater flexibility for developers who need to customize their Ad Services configurations.

SDK deprecation and sunset timelines activated

With this Android major version 24 launch and the iOS major version 12 launch last month, new deprecation and sunset dates for older releases are as follows:

  • Android Google Mobile Ads SDK versions 22.0.0 - 22.6.0 are officially deprecated, and will sunset in June 2026.
  • Android versions 21.x.x and iOS versions 9.x.x will sunset on June 30, 2025.
    • While there are currently no plans to disable ad serving on Android versions 21.x.x and iOS versions 9.x.x, we strongly recommend updating to the latest SDK version to avoid future impactions.

For a complete list of changes in v24.0.0 and detailed migration steps, check the release notes and SDK migration guide. If you have any questions or need additional help, contact us through Mobile Ads SDK Support.

Announcing iOS Google Mobile Ads SDK Version 12.0.0

Version 12.0.0 of the Google Mobile Ads SDK is now available. We recommend upgrading as soon as possible to get our latest features and performance improvements.

Updated Swift APIs

We’ve updated the Google Mobile Ads SDK to define an NS_SWIFT_NAME for every API to follow the naming conventions from Apple’s Swift API Design Guidelines. For example, we have:

  • Removed the GAD prefix across names for all types.
  • Renamed the GAM prefix to AdManager.
  • Renamed the GADM prefix to Mediation.

For the full list of Swift API name changes, see Swift naming support.

Swift 6 Concurrency

Swift 6 concurrency support is being rolled out incrementally, starting this release with added support for our ad format delegate methods. Future SDK versions will include further improvements.

Changes to Xcode requirements

The minimum supported Xcode version has been bumped to 16.0.

For the full list of changes, check the release notes. Check our migration guide to ensure your mobile apps are ready to upgrade.

SDK Deprecation Reminder

Per the deprecation schedule, the release of version 12.0.0 means that:

  • iOS Google Mobile Ads SDK versions 10.x.x are officially deprecated, and will sunset in Q2 2026.
  • Versions 9.x.x and below will sunset on June 30, 2025.
    • While there are currently no plans to disable ad serving on version 9.x.x, we strongly recommend updating to a supported SDK version to avoid being impacted in the future.

As always, if you have any questions or need additional help, contact us via the developer forum.

Use ad inspector to debug your mobile applications

Ad inspector is an in-app overlay that enables authorized devices to perform real-time analysis of Google Mobile Ads SDK test ad requests directly within your mobile app. It is included with the Google Mobile Ads SDK and you can enable it with no coding required.

Ad inspector empowers you to thoroughly test all your ad sources before releasing those changes to your users so you can verify everything is working properly. To help you understand and utilize ad inspector effectively, we published a 7-part ad inspector video series on our Google AdMob YouTube channel.

Each video focuses on a specific challenge in testing your ad integration, offering in-depth tutorials and demonstrations on how to:

Check out our ad inspector documentation (Android, iOS, Unity, Flutter) to learn more. If you have questions, comments, or general feedback about ad inspector, contact us in the developer forum. And remember to subscribe to our Google AdMob YouTube channel for more technical content.

Use ad inspector to debug your mobile applications

Ad inspector is an in-app overlay that enables authorized devices to perform real-time analysis of Google Mobile Ads SDK test ad requests directly within your mobile app. It is included with the Google Mobile Ads SDK and you can enable it with no coding required.

Ad inspector empowers you to thoroughly test all your ad sources before releasing those changes to your users so you can verify everything is working properly. To help you understand and utilize ad inspector effectively, we published a 7-part ad inspector video series on our Google AdMob YouTube channel.

Each video focuses on a specific challenge in testing your ad integration, offering in-depth tutorials and demonstrations on how to:

Check out our ad inspector documentation (Android, iOS, Unity, Flutter) to learn more. If you have questions, comments, or general feedback about ad inspector, contact us in the developer forum. And remember to subscribe to our Google AdMob YouTube channel for more technical content.

Reduce ANRs when implementing mobile ads

We heard your feedback via Play Console crash reports regarding Application Not Responding (ANRs) errors related to the Google Mobile Ads SDK. After analyzing these reports, we updated our SDK implementation best practices to reduce ANR rates. The recommended best practices are as follows:

  1. Initialize the Mobile Ads SDK on a background thread
  2. Enable optimization flag for ad loading

1. Initialize the Mobile Ads SDK on a background thread

Our previous best practice was to specify the OPTIMIZE_INITIALIZATION manifest flag. However, some work on the calling thread is still required to prepare MobileAds to handle other method calls synchronously.

We now recommend calling MobileAds.initialize() on a background thread, enabling the work required on the calling thread to happen in the background.

import com.google.android.gms.ads.MobileAds
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    CoroutineScope(Dispatchers.IO).launch {
      // Initialize the Google Mobile Ads SDK on a background thread.
      MobileAds.initialize(this@MainActivity) {}
      runOnUiThread {
        // Load an ad on the main thread.
        loadAd()
      }
    }
  }
}

Note: When calling MobileAds.initialize() on a background thread, the OPTIMIZE_INITIALIZATION manifest flag is no longer required.

2. Enable optimization flag for ad loading

By enabling the OPTIMIZE_AD_LOADING manifest flag, you can offload most ad loading tasks to a background thread. We recommend enabling this flag in your app's AndroidManifest.xml file to reduce the occurrence of ad loading causing ANRs.

<manifest>
  ...
  <application>
      ...
      <meta-data
          android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
          android:value="true"/>
  </application>
</manifest>

We’ve updated all of our Android example apps to implement these best practices. For more details on initialization and optimization flags, see Get started and Optimize initialization and ad loading. Contact us if you have any questions or need additional help.

Announcing Android Google Mobile Ads SDK Version 23.0.0

Version 23.0.0 of the Android Google Mobile Ads SDK is now available. We recommend upgrading as soon as possible to get our latest features and performance improvements.

The minimum Android API level is 21

Starting in version 23.0.0, the Google Mobile Ads SDK requires all apps to be on a minimum Android API level 21 to run. To adjust the API level, change the value of minSdk in your app-level build.gradle file to 21 or higher.

Ad Manager builder methods can now be chained

In version 23.0.0, AdManagerAdRequest.Builder methods inherited from its parent can be chained together to build an AdManagerAdRequest using a single call:

var newRequest = AdManagerAdRequest.Builder()
  .addCustomTargeting("age", "25") // AdManagerAdRequest.Builder method.
  .setContentUrl("https://www.example.com") // Method inherited from parent.
  .build() // Builds an AdManagerAdRequest.

A side effect of this change is AdManagerAdRequest.Builder no longer inherits from AdRequest.Builder.

SDK deprecation and sunset timelines activated

With this Android major version 23 launch and the iOS major version 11 launch last month, we are announcing new deprecation and sunset dates for older major releases. Specifically:

  • Android Google Mobile Ads SDK versions 21.x.x are officially deprecated, and will sunset in Q2 2025.
  • Android versions 20.x.x and iOS versions 8.x.x will sunset on June 30, 2024.
    • While there are currently no plans to disable ad serving on Android versions 20.x.x and iOS versions 8.x.x, we strongly recommend updating to a supported SDK version to avoid being impacted in the future.

For the full list of changes in v23.0.0, check the release notes. Check our migration guide to ensure your mobile apps are ready to upgrade. As always, if you have any questions or need additional help, contact us via the developer forum.

Announcing iOS Google Mobile Ads SDK Version 11.0.0

Today, we are announcing that version 11.0.0 of the Google Mobile Ads SDK is now available. We recommend upgrading as soon as possible to get our latest features and performance improvements.

Simplified SwiftUI development

Version 11.0.0 no longer requires publishers to declare a view controller to present full-screen ads. As a result, SwiftUI Publishers can now present full-screen ads without the need for UIKit or UIViewControllerRepresentable workarounds. See our SwiftUI guide for more information.

struct ContentView: View {
  private let adCoordinator = AdCoordinator()

  var body: some View {
    ...

    Button("Watch an ad") {
      adCoordinator.showAd()
    }
  }
}

private class InterstitialAdCoordinator: NSObject, GADFullScreenContentDelegate {
  private var interstitial: GADInterstitialAd?

  ...

  func showAd() {
    guard let interstitial = interstitial else {
      return print("Ad wasn't ready")
    }

    // The SDK uses the app's main window to look up view controllers
    // automatically when one is not provided.
    interstitial.present(fromRootViewController: nil)
  }
}

Continue collecting user metrics in AdMob

The Google Mobile Ads SDK dependency on GoogleAppMeasurement has been removed. This dependency that powered the user metrics toggle in AdMob will be discontinued in early 2024. To continue collecting user metrics in AdMob, link your AdMob app to Firebase and integrate the Google Analytics for Firebase SDK into your app.

Changes to minimum OS and Xcode requirements

  • The minimum OS version to load ads has been bumped from 12 to 13. Applications can still be built for iOS 12, but the SDK will only load ads on iOS 13 and higher.
  • The minimum supported Xcode version has been bumped to 15.1.

For the full list of changes, check the release notes. Check our migration guide to ensure your mobile apps are ready to upgrade.

SDK Deprecation Reminder

Per the deprecation schedule, the release of version 11.0.0 means that:

  • iOS Google Mobile Ads SDK versions 9.x.x are officially deprecated, and will sunset in Q2 2025.
  • Versions 8.x.x and below will sunset in Q2 2024, approximately 60 days following the release of Android Google Mobile Ads SDK major version 23.0.0.
    • While there are currently no plans to disable ad serving on version 8.x.x, we strongly recommend updating to a supported SDK version to avoid being impacted in the future.

As always, if you have any questions or need additional help, contact us via the developer forum.

We’ve Made Updates to the User Messaging Platform SDK APIs

In case you missed it, we announced new consent management platform requirements for serving ads in the EEA and UK. Beginning January 16, 2024, Google will require all publishers to use a Google-certified consent management platform (CMP) when serving ads to users in the European Economic Area or the UK.

In addition to growing our list of certified CMPs, we explored how to improve the User Messaging Platform (UMP) SDK developer experience for those who choose to use Google’s consent management solution. We are excited to share several updates in the latest iOS and Android versions that we think will streamline your integration.

Loading and presenting a consent form

The latest UMP SDK release introduces a new API, loadAndPresentIfRequired(), that consolidates the existing individual load and present consent form methods into a single method. The new API loads a consent form and if consent is required, automatically presents the consent form. This method is intended to be used at the beginning of a new app session.

Here is a code example of how to use the new API on iOS:

class ViewController: UIViewController {

  private var isMobileAdsStartCalled = false

  override func viewDidLoad() {
    super.viewDidLoad()

    UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) {
      [weak self] requestConsentError in
      guard let self else { return }

      // Call the helper method once consent information has been updated.
      UMPConsentForm.loadAndPresentIfRequired(from: self) {
        [weak self] loadAndPresentError in
        guard let self else { return }

        if UMPConsentInformation.sharedInstance.canRequestAds {
          self.startGoogleMobileAdsSDK()
        }
      }
    }

    // canRequestAds will be true if consent was gathered in the previous session.
    if UMPConsentInformation.sharedInstance.canRequestAds {
      startGoogleMobileAdsSDK()
    }
  }

  private func startGoogleMobileAdsSDK() {
    DispatchQueue.main.async {
      guard !self.isMobileAdsStartCalled else { return }

      self.isMobileAdsStartCalled = true

      // Initialize the Google Mobile Ads SDK.
      GADMobileAds.sharedInstance().start()
      // Request an ad.
      GADInterstitialAd.load(...)
    }
  }
}

Checking when to request ads

We added a new boolean property canRequestAds to use as a check before initializing the Google Mobile Ads SDK and requesting ads. canRequestAds returns true when the consent status is either OBTAINED or NOT_REQUIRED; as a result you don’t need to implement any enum checking yourself.

You should use the canRequestAds API in two places (as seen in the code snippet above):

  1. Once consent has been gathered in the current session.
  2. Immediately after you have called requestConsentInfoUpdate. It is possible consent has been gathered in the previous session in which case it is not necessary to wait for the callback to finish.

Checking privacy options requirement status

GDPR requires that publishers allow users to withdraw their consent choices at any time. It should be as easy to withdraw consent as it is to gather consent. To simplify this process, we have added two new APIs:

  1. privacyOptionsRequirementStatus to determine whether you should include a UI element that can re-present the consent form, such as a button in your application’s settings page.
  2. presentPrivacyOptionsForm() to show the form so the user can update their consent status at any time.

Here is a code example of how to use the new APIs on iOS:

// Show a privacy options button if required.
private var isPrivacySettingsButtonEnabled: Bool {
  return UMPConsentInformation.shared.privacyOptionsRequirementStatus == .required
}

// Present the privacy options form when a user interacts with your app.
@IBAction func privacySettingsTapped(_ sender: UIBarButtonItem) {
  UMPConsentForm.presentPrivacyOptionsForm(from: self) {
    [weak self] formError in
    guard let self, let formError else { return }

    // Handle the error.
  }
}

Developer resources

We updated our AdMob banner samples applications for iOS and Android to showcase integrating the UMP SDK. Keep an eye out as we add UMP SDK support to the rest of our samples soon.

Also take a look at our iOS and Android developer documentation for instructions on how to implement the UMP SDK.

If you have any questions or need additional help integrating the UMP SDK, please contact us via the developer forum.

Unity Google Mobile Ads Version 8 Released

We are excited to announce the release of Version 8 of the Google Mobile Ads for Unity plugin! This new version contains a number of new features and upgraded APIs.

Minimum Unity version is now 2019.4

The Google Mobile Ads Unity plugin now has a minimum Unity Engine version requirement of 2019.4. This was done to align with Unity’s long term support.

Compatibility with Android v22.0.0

This release supports the Android Google Mobile Ads SDK version 22.0.0 major version release.

User Messaging Platform (UMP) support

The Google Mobile Ads Unity plugin now includes support for the Google User Messaging Platform (UMP) to help you gather consent from app users. To enable UMP support, see the user privacy get started guide.

Plugin now has C# reference documentation

With the release of version 8, we now have launched C# reference documentation. Moreover, this version added xml-doc summaries to all public fields, properties, methods, and classes. This makes the plugin easier to use and provides full IntelliSense support when developing in Visual Studio.

Migrate ad format events to the new interface

Full-screen ad formats APIs now have a uniform interface and we are removing the old ad event APIs. These changes make the APIs for each ad format more consistent and easier to use. The new interface includes a static Load() method, use of generic delegates instead of EventArgs, and consistent ad events names across formats.

For a full list of changes and steps for upgrading your code, please see the version 8 migration guide.

Use RaiseAdEventsOnUnityMainThread() to guarantee thread safety

The Google Mobile Ads Unity plugin now includes an optional support feature for Unity thread safety. This feature means you no longer need to manage threading concerns when handling platform events or callbacks.

If you use this feature, the SDK may pause events during full screen ad presentations. This means that you might not get some events, like OnAdFullScreenContentOpened or OnAdImpressionRecorded, until after the user comes back to the game. If you need to collect this data in real time, this might not be a good option. We recommend you test this feature to see if it works for you.

Here's an example of how to use Google Mobile Ads new thread safety support:

Deprecation of Ad Placements

The Google Mobile Ads Unity plugin's Ad Placements feature is deprecated. There are no plans to move it into public release.

If you have any questions or concerns about migrating your project, please reach out on our developer forum.