AI アシスト出力の最適化を行うには、AI 環境にスキルを追加します。スキルを追加すると、Google Mobile Ads SDKに固有のコンテキストが AI ツールに提供され、AI アシストによるコード生成の出力が改善されます。
このガイドでは、Google Mobile Ads SDK 用に AI モデルを最適化する方法について説明します。
前提条件
Android Studio を使用する場合は、次の操作を行います。
- Gemini in Android Studio について学習します。
- Android Studio Panda 3 Canary 2 以降を使用して、 Gemini in Android Studio を設定します。
スキルを追加する
Google は、AI ツール用の SKILL.md ファイルを提供しています。このファイルには、次の統合手順に役立つ手順が記載されています。
- Google Mobile Ads SDK をプロジェクトに追加する。
- バナー広告を実装する。
AI ツールで Google Mobile Ads SDK 固有のスキルを使用する手順は次のとおりです。
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.フィードバックを送信
Google は、AI コード アシスト ツールの評価と最適化を継続して行い、Google Mobile Ads SDKのトピックに関するレスポンスを改善しています。
Gemini for Google Mobile Ads SDK の最適化に関するフィードバックがある場合は、 Google Mobile Ads SDK Discord チャンネルにご参加ください。