AI 도구와 Google 모바일 광고 SDK 통합

Android 스튜디오에서 Gemini를 최적화하려면 프로젝트에서 AGENTS.md 파일을 사용하세요. 프로젝트에 AGENTS.md 파일을 추가하면 Gemini에 Google Mobile Ads SDK 관련 컨텍스트를 제공하고 AI 지원 코드 생성의 출력을 개선할 수 있습니다. 자세한 내용은 AGENTS.md 파일을 사용하여 Gemini 맞춤설정하기를 참고하세요.

이 가이드에서는 Android 스튜디오에서 Google Mobile Ads SDK에 맞게 Gemini를 최적화하는 방법을 설명합니다.

시작하기 전에

계속하기 전에 다음을 수행하세요.

프로젝트에 AGENTS.md 파일 추가

Google에서는 다음 통합 단계를 지원하기 위해 Gemini에 대한 안내가 포함된 AGENTS.md 파일을 제공합니다.

  • 프로젝트에 Google Mobile Ads SDK를 추가합니다.
  • 배너 광고를 구현합니다.

AI 코드 어시스턴트에서 Google Mobile Ads SDK에 특화된 안내를 사용하려면 다음 단계를 따르세요.

  1. 프로젝트의 파일 시스템에서 아무 곳에나 AGENTS.md이라는 새 파일을 만듭니다.

  2. AGENTS.md 파일에 다음 안내를 추가합니다.

# AI Coding 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.

## Migrate to the GMA Next-Gen SDK

*   When I ask to migrate to the "Next Gen" SDK, **always** use the latest
    stable version for
    `com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk`.
*   Make sure the project meets the SDK requirements of `minSdk` 24 or higher
    and `compileSdk` of 35 or higher.
*   Replace the `com.google.android.gms:play-services-ads` dependency with the
    Next Gen `com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk`
    dependency.
*   All `com.google.android.gms.ads.*` import statements must change to
    `com.google.android.libraries.ads.mobile.sdk.*`.
    *   If the change is in a custom event adapter, ask me if I'm sure I want to
        migrate this class before making the change.
*   Preserve the `com.google.android.gms.ads.APPLICATION_ID` `<meta-data>` tag
    in the `AndroidManifest.xml` file if present.
*   YOU MUST analyze the code until all errors have been resolved. Resolve the
    errors by using the APIs from the GMA Next-Gen SDK. Refer to the Android
    documentation.

에이전트 모드에서 Gemini에 프롬프트 입력하기

AGENTS.md 파일을 구성한 후 Android 스튜디오에서 에이전트 모드로 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 Mobile Ads SDK에 맞게 Gemini를 최적화하는 데 관한 의견이 있으면 Google Mobile Ads SDK Discord 채널에 참여하세요.