[ Web Proxy ]
URL:
Viewing: https://developers.google.com/admob/android/optimize-initialization [Back]  [Original]

Optimize initialization and ad loading  |  Android  |  Google for Developers Skip to main content
Send feedback

Optimize initialization and ad loading Stay organized with collections Save and categorize content based on your preferences.

outlined_flag
Select platform: Unity Android (Legacy)

Starting from Google Mobile Ads (GMA) SDK version 21.0.0, you can enable optimized SDK initialization and ad loading to improve the overall responsiveness of ads and help prevent "Application Not Responding" (ANR) errors on your app. This guide outlines the changes you need to make to enable these optimizations.

Requirements

Before you continue, set up Google Mobile Ads SDK (Legacy).

Update your manifest file

There are two optimization flags available: OPTIMIZE_INITIALIZATION and OPTIMIZE_AD_LOADING. Once they're turned on, the initialization and ad loading tasks that require extended processing time are offloaded to background threads.

Follow the instructions below to add the corresponding <meta-data> tags in your app's AndroidManifest.xml file and turn on the flags. Note that you can turn on one or both options in the same app.

Important: Starting with Google Mobile Ads SDK (Legacy) version 24.0.0, the OPTIMIZE_INITIALIZATION and OPTIMIZE_AD_LOADING flags are set to true by default. In versions prior to 24.0.0, these flags are set to false by default.
Optimize Google Mobile Ads SDK (Legacy) initialization

The best way to optimize initialization is to call MobileAds.initialize() on a background thread, as described in the Get Started guide. If you are already doing so, you don't need to enable this flag.

If you must call the method on the main thread, enabling the flag below will move some of the initialization tasks to the background thread.

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

The flag below optimizes ad load calls for all ad formats:

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

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-15 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-15 UTC."],[],["To optimize Google Mobile Ads SDK, enable `OPTIMIZE_INITIALIZATION` and/or `OPTIMIZE_AD_LOADING` flags in your `AndroidManifest.xml`. These flags move time-consuming initialization and ad loading tasks to background threads, improving app responsiveness and preventing ANR errors. Add `\u003cmeta-data\u003e` tags within the `\u003capplication\u003e` tag, setting the desired flag's value to \"true.\" SDK version 21.0.0 or higher is required, with both flags being false by default.\n"]]

Web Proxy Viewer  |  New URL  |  Original Page