如要最佳化 AI 輔助輸出內容,請在 AI 環境中新增技能。新增技能後,AI 工具就能取得 Google Mobile Ads SDK (Legacy) 專屬的背景資訊,提升 AI 輔助生成程式碼的輸出品質。
本指南說明如何針對 Google Mobile Ads SDK (Legacy) 最佳化 AI 模型。
必要條件
請先完成下列事項,再繼續操作:
- 瞭解 Android Studio 內建 Gemini。
- 使用 Android Studio Panda 3 Canary 2 以上版本,在 Android Studio 中設定 Gemini。
新增技能
Google 提供 SKILL.md 檔案和操作說明,協助您完成下列整合步驟:
- 將 Google Mobile Ads SDK (Legacy) 新增至專案。
- 導入橫幅廣告。
如要在 Android Studio IDE 中將這項技能新增至專案,請按照下列步驟操作:
在專案的根目錄中,建立名為
.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`).
詳情請參閱「使用技能擴充代理模式」。
在提示中叫用技能
將技能新增至專案後,請使用下列範例提示叫用技能:
如要叫用技能,請輸入 @ 並選取「gma-android-integrate」技能。
整合 Google Mobile Ads SDK (Legacy)
@gma-android-integrate Integrate the latest version of Google Mobile Ads SDK (Legacy) to my project.新增橫幅
@gma-android-integrate Add an anchored adaptive banner ad to the bottom of the screen.提供意見
我們會持續評估及最佳化提供給 AI 程式設計助理的背景資訊,提升 Google Mobile Ads SDK (Legacy) 主題的回覆品質。
如果您對 Gemini Google Mobile Ads SDK (Legacy) 最佳化有任何意見,歡迎加入 Google Mobile Ads SDK (Legacy) Discord 頻道。