All skills
google avatar

/google-mobile-ads-rewarded

@329fa26
by googlegoogle/skills21k stars
1,698

Provides instructions for implementing, integrating, or configuring Google Mobile Ads (GMA) SDK rewarded ads in Android, iOS, or Unity mobile applications. Use when the task involves setting up rewarded ads. Don't use for "rewarded interstitial" ads.

Use this Skill: https://skilld.dev/gh/google/skills/google-mobile-ads-rewarded

This session only. Nothing lands on disk.

referencesandroid-rewarded.md

≈617 tokens on demand. Your agent reads this file only when SKILL.md points to it.

AI Integration Agent Instructions for Rewarded Ads

Required Imports

Use the following imports to implement a rewarded ad:

import com.google.android.libraries.ads.mobile.sdk.common.AdRequest
import com.google.android.libraries.ads.mobile.sdk.common.AdLoadCallback
import com.google.android.libraries.ads.mobile.sdk.common.FullScreenContentError
import com.google.android.libraries.ads.mobile.sdk.common.LoadAdError
import com.google.android.libraries.ads.mobile.sdk.rewarded.OnUserEarnedRewardListener
import com.google.android.libraries.ads.mobile.sdk.rewarded.RewardedAd
import com.google.android.libraries.ads.mobile.sdk.rewarded.RewardedAdEventCallback

Method Signatures

Use the following method signatures to implement rewarded ads:

The AdRequest object takes the ad unit ID:

AdRequest.Builder(adUnitId: String).build()

The method signature to load an ad from RewardedAd:

fun load(
    adRequest: AdRequest,
    adLoadCallback: AdLoadCallback<RewardedAd>
): Unit

The AdLoadCallback interface is defined as:

interface AdLoadCallback<T> {
    fun onAdLoaded(ad: T): Unit
    fun onAdFailedToLoad(adError: LoadAdError): Unit
}

Gotchas

UI Threading: MANDATORY: Callbacks in GMA-Next Gen SDK are invoked on a background thread. ALL UI-RELATED OPERATIONS (e.g., Toasts, View updates, Fragment transactions) MUST be wrapped in runOnUiThread {} or Dispatchers.Main.launch {} within GMA SDK callbacks. SKIPPING THIS STEP WILL CAUSE THE APPLICATION TO CRASH.

Rewarded ad workflow

  1. Load the ad

  2. Register for ad event callbacks

    • Set the adEventCallback on the RewardedAd object.
      • Drop the reference to the rewarded ad when the ad is dismissed or fails to show.
  3. Add a UI element to view the ad for a reward

    • Rewarded ads must never be shown automatically. Users must explicitly opt in.
    • Add a UI element, such as a button, that shows the ad upon user interaction.
  4. Show the ad

    • The show() method requires an OnUserEarnedRewardListener.
  5. Verify the implementation: Verify the build to ensure there are no compile errors:

    • Run gradle build -x test to confirm a successful clean build. Resolve any GMA SDK related compile errors.

Links

Additional documentation:

Source: SKILL.md on GitHub

No alerts8d3 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    This skill provides standard implementation guidelines for integrating the Google Mobile Ads (GMA) SDK rewarded ads across Android, iOS, and Unity platforms. It uses official Google documentation links and follows best practices for ad implementation, such as thread safety and user opt-in requirements. No security issues were detected.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

Signed by skilld at 329fa26. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last week
metadata
{
  "version": "1.1.0",
  "category": "GoogleAds"
}

README badge

README badge for google/skills/google-mobile-ads-rewarded