|
| 1 | +--- |
| 2 | +name: gma-integrate |
| 3 | +description: Provides technical specifications and implementation details for |
| 4 | + the play-services-ads Google Mobile Ads SDK |
| 5 | + (com.google.android.gms:play-services-ads), including Gradle dependencies, |
| 6 | + manifest metadata, initialization patterns, and banner ad configurations. Use |
| 7 | + ONLY for the play-services-ads Google Mobile Ads SDK. Do NOT use for GMA |
| 8 | + Next-Gen SDK (com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk) |
| 9 | + integrations. |
| 10 | +metadata: |
| 11 | + version: 1.0 |
| 12 | +--- |
| 13 | + |
| 14 | +# AI Integration Agent Instructions for the Play Services Google Mobile Ads SDK |
| 15 | + |
| 16 | +## SDK Integration Workflow |
| 17 | + |
| 18 | +* **Configure Gradle**: |
| 19 | + - [ ] Add the latest stable version of |
| 20 | + `com.google.android.gms:play-services-ads` to dependencies. |
| 21 | + - [ ] Configure `minSdk` (23+) and `compileSdk` (35+). |
| 22 | + - [ ] Sync Gradle before moving on to the next step. |
| 23 | +* **Manifest Configuration**: |
| 24 | + - [ ] Add the following metadata to the `<application>` tag in the |
| 25 | + `AndroidManifest.xml` file: |
| 26 | + ```xml |
| 27 | + <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 --> |
| 28 | + <meta-data |
| 29 | + android:name="com.google.android.gms.ads.APPLICATION_ID" |
| 30 | + android:value="ca-app-pub-3940256099942544~3347511713"/> |
| 31 | + ``` |
| 32 | + **Note**: The sample AdMob App ID |
| 33 | + `ca-app-pub-3940256099942544~3347511713` is for testing purposes only. |
| 34 | + **ALWAYS** remind the user to replace it with their actual AdMob App ID |
| 35 | + before publishing. |
| 36 | +* **Initialize SDK**: |
| 37 | + - [ ] Initialize SDK on a background thread. |
| 38 | + |
| 39 | +### Implementation Details |
| 40 | + |
| 41 | +* **Version Management**: **ALWAYS** look up and use the latest stable |
| 42 | + version. Do not assume a version number. |
| 43 | +* **Initialization**: **ALWAYS** call `MobileAds.initialize()` on a background |
| 44 | + thread. |
| 45 | + |
| 46 | +## Banner Ads |
| 47 | + |
| 48 | +Banner ads are rectangular image or text ads that occupy a spot within an app's |
| 49 | +layout. They remain on screen during user interaction and can refresh |
| 50 | +automatically. |
| 51 | + |
| 52 | +### Strategic Recommendations |
| 53 | + |
| 54 | +* **Confirm Ad Type**: If the user asks for a "banner ad" without specifying a |
| 55 | + type, confirm the desired type. |
| 56 | +* **Suggest Large Anchored Adaptive**: Suggest large anchored adaptive banners |
| 57 | + over "fixed size". Explain they are designed to increase engagement and |
| 58 | + revenue potential. If told that large adaptive is too large, suggest |
| 59 | + standard anchored adaptive over fixed size ads. |
| 60 | +* **Type Clarifications**: |
| 61 | + * **Anchored Adaptive**: Ask if it should be anchored to the **top** or |
| 62 | + **bottom**. |
| 63 | + * **Inline Adaptive**: Use this type for ads placed inside scrollable |
| 64 | + content (e.g., `RecyclerView` or `ScrollView`). **Validate** the ad |
| 65 | + container is scrollable before implementing; if not scrollable, default |
| 66 | + to **Large Anchored Adaptive**. |
| 67 | + |
| 68 | +### Implementation Checklist |
| 69 | + |
| 70 | +- [ ] Create UI container for `AdView`. |
| 71 | +- [ ] Initialize `AdView` with ad unit ID and ad size. |
| 72 | +- [ ] Call `adView.loadAd()`. |
| 73 | +- [ ] **Mandatory**: Add `adView.destroy()` to the appropriate lifecycle |
| 74 | + cleanup (e.g., `onDestroy`). |
0 commit comments