Integra el SDK de anuncios de Google para dispositivos móviles con herramientas de IA (beta)

Para optimizar el resultado asistido por IA, agrega una habilidad a tu entorno de IA. Cuando agregas una habilidad, le proporcionas a tu herramienta de IA contexto específico para Google Mobile Ads SDK y mejoras el resultado de la generación de código asistida por IA.

En esta guía, se explica cómo optimizar tu modelo de IA para Google Mobile Ads SDK.

Requisitos previos

Si usas Android Studio, haz lo siguiente:

Cómo agregar una habilidad

Google proporciona un archivo SKILL.md con instrucciones para que tu herramienta de IA te ayude con los siguientes pasos de integración:

  • Agrega Google Mobile Ads SDK a tu proyecto.
  • Implementa anuncios de banner.

Para usar una habilidad específica de Google Mobile Ads SDK con tu herramienta de IA, sigue estos pasos:

Android Studio

  1. En el directorio raíz del proyecto, crea una carpeta llamada .skills/.

  2. Crea un directorio para tu skill llamado gma-android-integrate.

  3. En el directorio gma-android-integrate, crea un archivo llamado SKILL.md.

  4. En tu archivo SKILL.md, agrega las siguientes instrucciones:

    ---
    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`).

    Para obtener más información, consulta Extiende el modo agente con habilidades.

Invoca la habilidad en tu instrucción

Después de agregar la habilidad a tu proyecto, usa los siguientes ejemplos de instrucciones para invocarla en tu herramienta de IA:

Android Studio

Para invocar la skill, escribe @ y selecciona la skill de gma-android-integrate.

Integrar Google Mobile Ads SDK

@gma-android-integrate Integrate the latest version of Google Mobile Ads SDK to my project.

Cómo agregar un banner

@gma-android-integrate Add an anchored adaptive banner ad to the bottom of the screen.

Enviar comentarios

Seguimos evaluando y optimizando el contexto que se proporciona a las herramientas de asistencia de código con IA para mejorar sus respuestas sobre temas relacionados con Google Mobile Ads SDK.

Si tienes comentarios sobre la optimización de Gemini para Google Mobile Ads SDK, únete al canal de Discord de Google Mobile Ads SDK.