Para otimizar o Gemini no Android Studio, use um arquivo AGENTS.md no seu projeto.
Ao adicionar um arquivo AGENTS.md ao projeto, você fornece ao Gemini um contexto específico para Google Mobile Ads SDK e melhora a saída da geração de código assistida por IA. Para mais detalhes, consulte Personalizar o Gemini usando arquivos AGENTS.md.
Este guia aborda a otimização do Gemini no Android Studio para Google Mobile Ads SDK.
Antes de começar
Antes de continuar, faça o seguinte:
- Saiba Sobre o Gemini no Android Studio.
- Configure o Google Mobile Ads SDK usando uma versão compatível do Android Studio.
Adicionar o arquivo AGENTS.md ao projeto
O Google fornece um arquivo AGENTS.md com instruções para o Gemini ajudar você
com as seguintes etapas de integração:
- Adicione Google Mobile Ads SDK ao seu projeto.
- Implemente anúncios de banner.
Para usar instruções específicas do Google Mobile Ads SDK na assistência de código de IA, siga estas etapas:
Crie um arquivo chamado
AGENTS.mdem qualquer lugar do sistema de arquivos do projeto.No arquivo
AGENTS.md, adicione estas instruções:
# 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.
Comandar o Gemini no modo Agente
Depois de configurar o arquivo AGENTS.md, você pode pedir ajuda ao Gemini no Android Studio
no modo agente.
No Modo Agente, você pode usar os seguintes exemplos de comandos:
Integrar o SDK
Integrate the latest version of the GMA SDK to my project. Refer to the Android
documentation.
Adicionar um banner
Add an anchored adaptive banner ad to the bottom of the screen. Refer to the
Android documentation.
Enviar feedback
Continuamos avaliando e otimizando o contexto fornecido às ferramentas de assistência de código de IA para melhorar as respostas sobre temas de Google Mobile Ads SDK.
Se você tiver feedback sobre a otimização do Gemini para Google Mobile Ads SDK, participe do canal do Discord do Google Mobile Ads SDK.