如要最佳化 AI 輔助輸出內容,請在 AI 環境中新增技能。新增技能後,AI 工具就能取得特定背景資訊,並提升 AI 輔助程式碼生成的輸出品質。Google Mobile Ads SDK
本指南說明如何針對 Google Mobile Ads SDK 最佳化 AI 模型。
必要條件
如果您使用 Android Studio,請執行下列操作:
- 瞭解 Android Studio 內建 Gemini。
- 使用 Android Studio Panda 3 Canary 2 以上版本,在 Android Studio 內建 Gemini 中設定 Gemini。
新增技能
Google 會提供 SKILL.md 檔案,內含 AI 工具的相關操作說明,協助您完成下列整合步驟:
- 將 Google Mobile Ads SDK 新增至專案。
- 導入橫幅廣告。
如要使用 Google Mobile Ads SDK 專屬技能搭配 AI 工具,請按照下列步驟操作:
Android Studio
在專案的根目錄中,建立名為
.skills/的資料夾。為技能建立名為
gma-android-integrate的目錄。在
gma-android-integrate目錄中,建立名為SKILL.md的檔案。在
SKILL.md檔案中,新增下列指令:--- name: gma-android-integrate description: Provides technical specifications and implementation details for the play-services-ads Google Mobile Ads SDK (com.google.android.gms:play-services-ads), including Gradle dependencies, manifest metadata, initialization patterns, and banner ad configurations. Use ONLY for the play-services-ads Google Mobile Ads SDK. Do NOT use for GMA Next-Gen SDK (com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk) integrations. metadata: version: 1.0 --- # AI Integration Agent Instructions for the Play Services Google Mobile Ads SDK ## SDK Integration Workflow * **Configure Gradle**: - [ ] Add the latest stable version of `com.google.android.gms:play-services-ads` to dependencies. - [ ] Configure `minSdk` (23+) and `compileSdk` (35+). - [ ] Sync Gradle before moving on to the next step. * **Manifest Configuration**: - [ ] Add the following metadata to the `<application>` tag in the `AndroidManifest.xml` file: ```xml <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 --> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713"/> ``` **Note**: The sample AdMob App ID `ca-app-pub-3940256099942544~3347511713` is for testing purposes only. **ALWAYS** remind the user to replace it with their actual AdMob App ID before publishing. * **Initialize SDK**: - [ ] Initialize SDK on a background thread. ### Implementation Details * **Version Management**: **ALWAYS** look up and use the latest stable version. Do not assume a version number. * **Initialization**: **ALWAYS** call `MobileAds.initialize()` on a background thread. ## Banner Ads Banner ads are rectangular image or text ads that occupy a spot within an app's layout. They remain on screen during user interaction and can refresh automatically. ### Strategic Recommendations * **Confirm Ad Type**: If the user asks for a "banner ad" without specifying a type, confirm the desired type. * **Suggest Large Anchored Adaptive**: Suggest large anchored adaptive banners over "fixed size". Explain they are designed to increase engagement and revenue potential. If told that large adaptive is too large, suggest standard anchored adaptive over fixed size ads. * **Type Clarifications**: * **Anchored Adaptive**: Ask if it should be anchored to the **top** or **bottom**. * **Inline Adaptive**: Use this type for ads placed inside scrollable content (e.g., `RecyclerView` or `ScrollView`). **Validate** the ad container is scrollable before implementing; if not scrollable, default to **Large Anchored Adaptive**. ### Implementation Checklist - [ ] Create UI container for `AdView`. - [ ] Initialize `AdView` with ad unit ID and ad size. - [ ] Call `adView.loadAd()`. - [ ] **Mandatory**: Add `adView.destroy()` to the appropriate lifecycle cleanup (e.g., `onDestroy`).
詳情請參閱「使用技能擴充代理程式模式」。
在提示中叫用技能
將技能新增至專案後,請使用下列範例提示,在 AI 工具中叫用技能:
Android Studio
如要叫用技能,請輸入 @ 並選取 gma-android-integrate 技能。
整合 Google Mobile Ads SDK
@gma-android-integrate Integrate the latest version of Google Mobile Ads SDK to my project.新增橫幅
@gma-android-integrate Add an anchored adaptive banner ad to the bottom of the screen.提供意見
我們會持續評估並調整提供給 AI 程式碼輔助工具的內容,以改善工具對Google Mobile Ads SDK主題的回覆。
如要提供有關最佳化 Gemini for Google Mobile Ads SDK 的意見回饋,請加入 Google Mobile Ads SDK Discord 頻道。