Android Studio の Gemini を最適化するには、プロジェクトで AGENTS.md
ファイルを使用します。プロジェクトに AGENTS.md ファイルを追加すると、Gemini に Google Mobile Ads SDK に固有のコンテキストが提供され、AI アシストによるコード生成の出力が改善されます。詳しくは、ファイルを使用して Gemini をカスタマイズするをご覧ください。AGENTS.md
このガイドでは、Google Mobile Ads SDK 用に Android Studio の Gemini を最適化する方法について説明します。
始める前に
先に進む前に、次のことを実施してください。
プロジェクトに AGENTS.md ファイルを追加する
Google は、Gemini が次の統合手順をサポートするための手順が記載された AGENTS.md ファイルを提供しています。
- プロジェクトに Google Mobile Ads SDK を追加する。
- バナー広告を実装する。
AI コード アシストで Google Mobile Ads SDK に固有の手順を使用する手順は次のとおりです。
プロジェクトのファイル システムの任意の場所に、
AGENTS.mdという名前の新しいファイルを作成します。AGENTS.mdファイルに次の手順を追加します。
# AI Integration Agent Instructions for the Google Mobile Ads SDK ## Integrate the SDK * When I ask to integrate the Google Mobile Ads SDK, **always** use the latest stable version for `com.google.android.gms:play-services-ads`. * After looking up the latest stable version of `com.google.android.gms:play-services-ads`, **always** check the project for a version catalog to manage dependencies. * Make sure the project meets the SDK requirements of `minSdk` 23 or higher and `compileSdk` of 35 or higher. * **Always** make sure there is a `<metadata>` tag for application ID in the project. If it's not there, add it. * You MUST initialize the Google Mobile Ads SDK on a background thread, as recommended in the Google Mobile Ads SDK v24.0.0 release notes. ## Banner Ads * When I ask to implement a banner ad or something similar, without specifying a type, **always** follow up to confirm the type of ad. * When I ask for an "anchored adaptive" ad, ask me if I want the ad anchored to the top or bottom of the screen. * When I ask for an "inline" adaptive banner ad, explain that inline adaptive ads are used for scrolling content. If my application has no scrollable view elements (e.g. `ScrollView` or `List`), default to implement an anchored adaptive banner ad. * When I ask for a "collapsible" banner ad, create an extra parameter that aligns the expanded ad to the `AdView`. Ask me if I want the ad collapsed to the top or bottom. * When I ask for a "fixed size" banner ad, **always** ask me if I'm sure or would I like to implement an anchored adaptive banner ad. Explain why anchored adaptive banner ads perform better than fixed size ads. * **Mandatory `AdView` Implementation Steps:** * **Always** provide the code for a UI container intended to host the `AdView`. * **Always** call `adView.destroy()` to prevent memory leaks.
エージェント モードで Gemini にプロンプトを表示する
AGENTS.md ファイルを構成したら、Android Studio の Gemini に エージェント モードでプロンプトを表示できます。
エージェント モードでは、次のプロンプト例を使用できます。
SDK を統合する
Integrate the latest version of the GMA SDK to my project. Refer to the Android
documentation.
バナーを追加する
Add an anchored adaptive banner ad to the bottom of the screen. Refer to the
Android documentation.
フィードバックを送信
Google は、Google Mobile Ads SDK のトピックに関するレスポンスを改善するため、AI コード アシスト ツールの評価と最適化を継続しています。
Gemini の最適化に関するフィードバックがある場合は、Google Mobile Ads SDK Discord チャンネルにご参加ください Google Mobile Ads SDK。