Request: mention special requirements about functions in docs of the new Admob beta SDK

5 views
Skip to first unread message

Liran Barsisa

unread,
3:00 PM (2 hours ago) 3:00 PM
to Google Mobile Ads SDK Developers
I'm talking about this:
implementation("com.google.android.gms:play-services-ads:24.9.0")

Whenever a function needs to run on the UI/background thread, it should be mentioned in docs and together with annotation.

In addition, I've noticed that the function of MobileAds.setRequestConfiguration requires that we first finish calling MobileAds.initialize, and it's not mentioned on the docs:

All it says is: "
Sets the global RequestConfiguration that will be used for every AdRequest during the app's session.
"

In the past, it was actually ok to use it anywhere. If I try it before, it will cause an exception.

Now, if you check on the sample, it shows it being used as such:

https://github.com/googleads/gma-next-gen-sdk-android-examples/blob/df6cb62848cd295d28e886a83fa51de84ac7c661/kotlin/NextGenExample/app/src/main/java/com/example/next_gen_example/SplashActivity.kt#L145

    backgroundScope.launch {
      // Initialize the Google Mobile Ads SDK on a background thread.
      MobileAds.initialize(
        this@SplashActivity,
        // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
        InitializationConfig.Builder(APP_ID).build(),
      ) {
        // Adapter initialization is complete.
      }

      // Set your test devices.
      MobileAds.setRequestConfiguration(
        RequestConfiguration.Builder()
          .setTestDeviceIds(listOf(Constant.TEST_DEVICE_HASHED_ID))
          .build()
      )

      if (googleMobileAdsConsentManager.canRequestAds) {
        // Load an app open ad when Mobile Ads SDK initialization is complete.
        AppOpenAdManager.loadAd(this@SplashActivity)
      }
    }
  }

Liran Barsisa

unread,
3:34 PM (2 hours ago) 3:34 PM
to Google Mobile Ads SDK Developers
Reply all
Reply to author
Forward
0 new messages