Оптимизируйте инициализацию и загрузку рекламы

Выберите платформу: Android Unity

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.

Требования

Прежде чем продолжить, настройте Google Mobile Ads SDK .

  • Версия Google Mobile Ads SDK 21.0.0 или выше.

Обновите файл манифеста.

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.

Оптимизация инициализации Google Mobile Ads SDK

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.

Если вам необходимо вызвать метод в основном потоке, включение указанного ниже флага перенесет некоторые задачи инициализации в фоновый поток.

<manifest>
  ...
  <application>
      ...
      <meta-data
          android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION"
          android:value="true"/>
  </application>
</manifest>
Оптимизация загрузки рекламы

Указанный ниже флаг оптимизирует вызовы загрузки рекламы для всех форматов объявлений:

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