google-mobile-ads-android-migrate-to-next-gen
यह क्या करती है
यह पुरानी Google Mobile Ads लाइब्रेरी को Next-Gen SDK से बदलने के चरण समझाती है, जिसमें classes और methods के लिए मैपिंग टेबल इस्तेमाल होती हैं। यह मौजूदा विज्ञापन सेटअप वाले Android डेवलपर्स के लिए है।
कब इस्तेमाल करें
- ✓जब आपका Android ऐप पुरानी Google Mobile Ads SDK इस्तेमाल करता हो और आप Next-Gen पर जाना चाहते हों।
- ✓जब आपको कई फ़ाइलों में पुराने विज्ञापन imports और method calls अपडेट करने हों।
- ✓जब डुप्लीकेट विज्ञापन लाइब्रेरी symbols की वजह से बिल्ड विफल हो।
Skill का लिंक
https://github.com/google/skills/blob/main/skills/ads/google-mobile-ads-android-migrate-to-next-gen/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे Android ऐप को पुरानी Google Mobile Ads SDK से Next-Gen SDK में माइग्रेट कीजिए, और पक्का कीजिए कि वह बिल्ड हो जाए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह एक चेकलिस्ट फ़ॉलो करती है: Gradle dependency अपडेट करना, न्यूनतम और compile SDK संस्करण बढ़ाना, पुरानी लाइब्रेरी हटाना, मैपिंग टेबल से हर फ़ाइल माइग्रेट करना, फिर एक साफ़ बिल्ड चलाना।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
AI Migration Agent Instructions for the Google Mobile Ads SDK
Migration Workflow
Use this checklist to track your migration progress:
- Configure Gradle:
Replace
com.google.android.gms:play-services-adswith the latest stable version ofcom.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk. If you cannot access Maven directly, run the following command to fetch the latest version. The version returned in thelatesttag is the latest version of the GMA Next-Gen SDK:curl -sS https://dl.google.com/dl/android/maven2/com/google/android/libraries/ads/mobile/sdk/ads-mobile-sdk/maven-metadata.xml | sed -n 's/.*<latest>\(.*\)<\/latest>.*/\1/p'Update
minSdk(24+) andcompileSdk(34+).Exclude
play-services-adsandplay-services-ads-litefrom all dependencies globally in the app-level build file to avoid duplicate symbol errors.Sync Gradle before moving on to the next step.
- Per-File Migration:
- Refactor the codebase following the API Mapping and Method Mapping tables to migrate imports, class names, and method signature to GMA Next-Gen SDK.
- Verify and Build:
- Run
gradle build -x testto confirm a successful clean build. Resolve any GMA SDK related compile errors.
- Run
Core Migration Rules
- App ID Usage: Always use the value of the
com.google.android.gms.ads.APPLICATION_IDmeta-data tag fromAndroidManifest.xmlfor theapplicationIdinInitializationConfig.- Constraint: Preserve the
<meta-data>tag in the manifest; it is still required for publishers using the User Messaging Platform SDK.
- Constraint: Preserve the
- Initialization Sequence:
- Call
MobileAds.initialize()on a background thread. - Ensure
initialize()is called before any other SDK methods. - If using
RequestConfiguration, bundle it intoInitializationConfig.Builder.setRequestConfiguration(). Do not callMobileAds.setRequestConfiguration()before initialization.
- Call
- UI Threading: MANDATORY: Callbacks in GMA-Next Gen SDK are invoked
on a background thread. ALL UI-RELATED OPERATIONS (e.g., Toasts, View
updates, Fragment transactions) MUST be wrapped in
runOnUiThread {}orDispatchers.Main.launch {}within GMA SDK callbacks. SKIPPING THIS STEP WILL CAUSE THE APPLICATION TO CRASH. - Mediation: Classes implementing
com.google.android.gms.ads.mediation.AdapterMUST continue usingcom.google.android.gms.ads.
Format Specifics
Banner Ads
- Use
com.google.android.libraries.ads.mobile.sdk.banner.AdViewfor loading GMA Next-Gen SDK banners. - The following API checks if a banner is collapsible:
adView.getBannerAd().isCollapsible().
Native Ads
- NativeAdLoader:
NativeAdLoaderis abstract and cannot be instantiated. It is used statically (e.g.,NativeAdLoader.load(...)). - The following APIs are now set on the
NativeAdRequest.Builder:.setCustomFormatIds(customFormatIds: List<String>).disableImageDownloading().setMediaAspectRatio(mediaAspectRatio: NativeMediaAspectRatio).setAdChoicesPlacement(adChoicesPlacement: AdChoicesPlacement).setVideoOptions(videoOptions: VideoOptions)
- Removal: Delete all "Mute This Ad" logic; it is unsupported in GMA Next-Gen SDK.
- MediaView:
NativeAdno longer has a directmediaViewvariable; useregisterNativeAd(nativeAd, mediaView)to associate the ad with the view.
Ad preloading
- Unless specified in the mapping table, ad preloading methods in the GMA Next-Gen SDK retain the same API signatures and parameters as the Old SDK.
API Mapping
This table covers the main classes and their GMA Next-Gen SDK equivalents.
| Feature | Old SDK Import (com.google.android.gms.ads...) |
GMA Next-Gen SDK Import (com.google.android.libraries.ads.mobile.sdk... ) |
|---|
अक्सर पूछे जाने वाले सवाल
क्या यह मेरे लिए SDK dependency अपडेट करती है?
हाँ। यह पुरानी Gradle dependency को नवीनतम स्थिर Next-Gen संस्करण से बदलती है।
इसके लिए कौन से Android संस्करण चाहिए?
चेकलिस्ट में न्यूनतम SDK 24 और compile SDK 34 या उससे ऊपर चाहिए।
क्या यह जाँचती है कि बिल्ड पास हो?
हाँ। यह माइग्रेशन की पुष्टि के लिए एक साफ़ बिल्ड के साथ खत्म होती है।
जानकारी
लेखक का मूल विवरण
Migrates Android applications from the old, legacy Google Mobile Ads (GMA) SDK (com.google.android.gms:play-services-ads) to the new GMA Next-Gen SDK (com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk). Provides comprehensive mapping tables for imports, classes, and method signatures to help determine migration steps. Use when migrating an existing Android codebase from the old, legacy GMA SDK to GMA Next-Gen SDK.
repo: google/skills
लोकप्रियता
- GitHub स्टार
- 22k
- रैंकिंग में स्थान
- #10188
- लाइसेंस
- Apache-2.0
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
finding-google-skills
22kआपके एजेंट को किसी सेटअप काम के लिए सही Google गाइड खोजने में मदद करती है, जैसे hosting, databases, storage, sign-in या AI model serving।
gcloud
22kयह आपके एजेंट को Google Cloud gcloud कमांड लिखने और जाँचने में मदद करती है, कुछ भी चलाने से पहले सटीक सिंटैक्स देखकर, ताकि फ़्लैग का अंदाज़ा न लगे।
google-cloud-recipe-auth
22kआपके एजेंट को Google Cloud की पहचान और पहुँच समझाती है, जिसमें यह शामिल है कि लोग और सेवाएँ कैसे साइन इन करते हैं और उन्हें कौन सी अनुमतियाँ मिलती हैं।
google-cloud-recipe-onboarding
22kएक नए डेवलपर को Google Cloud पर पहले कदमों में मदद करती है, जिसमें प्रोजेक्ट चुनना, बिलिंग जोड़ना और पहला संसाधन डिप्लॉय करना शामिल है।
मिलती-जुलती skills
android-clean-architecture
280kयह आपके एजेंट को Android projects को व्यवस्थित तरीके से संभालने देता है। यह code को ऐसा ढांचा देता है कि उसकी देखभाल और नए features जोड़ना आसान हो।
compose-multiplatform-patterns
280kKMP projects में Compose Multiplatform और Jetpack Compose patterns इस्तेमाल करने में आपके एजेंट की मदद करता है। इसमें state, navigation, theming और performance शामिल हैं।
dart-flutter-patterns
280kयह आपके एजेंट को Dart और Flutter apps के लिए code लिखने देता है। यह आधुनिक patterns इस्तेमाल करके मज़बूत और आसानी से संभलने वाले apps बनाता है।