最佳化初始化和廣告載入 (Beta 版)

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 in your app's AndroidManifest.xml file for optimization to take effect.

Requirements

  • Complete the Get Started guide.
  • Use Google Mobile Ads SDK version 21.0.0 or higher.

Update your manifest file

There are two optimization flags available: OPTIMIZE_INITIALIZATION and OPTIMIZE_AD_LOADING. Once they are turned on, the initialization and ad loading tasks that require extended processing time will be offloaded to the 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.

Optimize GMA SDK initialization

The flag below optimizes the MobileAds.initialize() initialization call:

<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>