Để tối ưu hoá kết quả đầu ra do AI hỗ trợ, hãy thêm một kỹ năng vào môi trường AI. Bằng cách thêm một kỹ năng, bạn sẽ cung cấp cho công cụ AI của mình bối cảnh dành riêng cho Google Mobile Ads SDK và cải thiện kết quả đầu ra của quá trình tạo mã do AI hỗ trợ.
Hướng dẫn này trình bày cách tối ưu hoá mô hình AI cho Google Mobile Ads SDK.
Điều kiện tiên quyết
Nếu bạn sử dụng Android Studio, hãy làm như sau:
- Tìm hiểu về Gemini trong Android Studio.
- Thiết lập Gemini trong Android Studio bằng Android Studio Panda 3 Canary 2 trở lên.
Thêm kỹ năng
Google cung cấp tệp SKILL.md có hướng dẫn cho công cụ AI để giúp bạn thực hiện các bước tích hợp sau:
- Thêm Google Mobile Ads SDK vào dự án của bạn.
- Triển khai quảng cáo biểu ngữ.
Để sử dụng một kỹ năng dành riêng cho Google Mobile Ads SDK với công cụ AI, hãy làm theo các bước sau:
Android Studio
Trong thư mục gốc của dự án, hãy tạo một thư mục có tên là
.skills/.Tạo một thư mục cho kỹ năng của bạn có tên là
gma-android-integrate.Trong thư mục
gma-android-integrate, hãy tạo một tệp có tên làSKILL.md.Trong tệp
SKILL.md, hãy thêm các hướng dẫn sau:--- 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`).
Để biết thông tin chi tiết, hãy xem bài viết Mở rộng Chế độ tác nhân bằng các kỹ năng.
Gọi kỹ năng trong lời nhắc
Sau khi thêm kỹ năng vào dự án, hãy sử dụng các lời nhắc mẫu sau để gọi kỹ năng đó trong công cụ AI:
Android Studio
Để gọi kỹ năng, hãy nhập @ rồi chọn kỹ năng gma-android-integrate.
Tích hợp Google Mobile Ads SDK
@gma-android-integrate Integrate the latest version of Google Mobile Ads SDK to my project.Thêm biểu ngữ
@gma-android-integrate Add an anchored adaptive banner ad to the bottom of the screen.Gửi phản hồi
Chúng tôi đang tiếp tục đánh giá và tối ưu hoá bối cảnh được cung cấp cho các công cụ hỗ trợ viết mã bằng AI để cải thiện phản hồi của các công cụ này về các chủ đề liên quan đến Google Mobile Ads SDK.
Nếu bạn có ý kiến phản hồi về việc tối ưu hoá Gemini cho Google Mobile Ads SDK, hãy tham gia Google Mobile Ads SDK kênh Discord.