Para optimizar Gemini en Android Studio, usa un archivo AGENTS.md en tu proyecto.
Si agregas un archivo AGENTS.md a tu proyecto, le proporcionas a Gemini un contexto
específico de Google Mobile Ads SDK y mejoras el resultado de la generación de código
asistida por IA. Para obtener más detalles, consulta Cómo personalizar Gemini con AGENTS.md
archivos.
En esta guía, se explica cómo optimizar Gemini en Android Studio para Google Mobile Ads SDK.
Antes de comenzar
Antes de continuar, haz lo siguiente:
- Obtén información sobre Gemini en Android Studio.
- Configura Gemini en Android Studio con una versión compatible de Android Studio.
Agrega el archivo AGENTS.md a tu proyecto
Google proporciona un archivo AGENTS.md con instrucciones para que Gemini te ayude con los siguientes pasos de integración:
- Agrega Google Mobile Ads SDK a tu proyecto.
- Implementa anuncios de banner.
Para usar instrucciones específicas de Google Mobile Ads SDK en la asistencia de código de IA, sigue estos pasos:
Crea un archivo nuevo llamado
AGENTS.mden cualquier lugar del sistema de archivos de tu proyecto.En tu archivo
AGENTS.md, agrega las siguientes instrucciones:
# 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.
Solicita a Gemini en el modo de agente
Después de configurar tu archivo AGENTS.md, puedes solicitar a Gemini en Android Studio
en el modo de agente.
En el modo de agente, puedes usar los siguientes ejemplos de instrucciones:
Integra el SDK.
Integrate the latest version of the GMA SDK to my project. Refer to the Android
documentation.
Agrega un banner.
Add an anchored adaptive banner ad to the bottom of the screen. Refer to the
Android documentation.
Enviar comentarios
Seguimos evaluando y optimizando el contexto proporcionado a las herramientas de asistencia de código de IA para mejorar sus respuestas sobre temas de Google Mobile Ads SDK.
Si tienes comentarios sobre la optimización de Gemini para Google Mobile Ads SDK, únete al Google Mobile Ads SDK canal de Discord.