Aller au contenu
Skillpedia
Applis mobiles22k · #10188

google-mobile-ads-android-migrate-to-next-gen

Ce qu’il fait

Il guide le remplacement de l'ancienne bibliothèque Google Mobile Ads par le SDK Next-Gen, à l'aide de tables de correspondance pour les classes et les méthodes. Il s'adresse aux développeurs Android qui ont déjà une intégration publicitaire.

Quand l’utiliser

  • ✓Quand votre app Android utilise l'ancien SDK Google Mobile Ads et que vous voulez passer à Next-Gen.
  • ✓Quand vous devez mettre à jour d'anciens imports et appels de méthodes publicitaires dans de nombreux fichiers.
  • ✓Quand une compilation échoue à cause de symboles de bibliothèque publicitaire en double.

Lien du skill

https://github.com/google/skills/blob/main/skills/ads/google-mobile-ads-android-migrate-to-next-gen/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/google/skills/blob/main/skills/ads/google-mobile-ads-android-migrate-to-next-gen/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Migre mon app Android de l'ancien SDK Google Mobile Ads vers le SDK Next-Gen, et assure-toi qu'elle se compile.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

Il suit une liste de contrôle : mise à jour de la dépendance Gradle, relèvement des versions minimale et de compilation du SDK, suppression des anciennes bibliothèques, migration de chaque fichier à l'aide des tables de correspondance, puis compilation propre.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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-ads with the latest stable version of com.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 the latest tag 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+) and compileSdk (34+).

    • Exclude play-services-ads and play-services-ads-lite from 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 test to confirm a successful clean build. Resolve any GMA SDK related compile errors.

Core Migration Rules

  • App ID Usage: Always use the value of the com.google.android.gms.ads.APPLICATION_ID meta-data tag from AndroidManifest.xml for the applicationId in InitializationConfig.
    • Constraint: Preserve the <meta-data> tag in the manifest; it is still required for publishers using the User Messaging Platform SDK.
  • Initialization Sequence:
    1. Call MobileAds.initialize() on a background thread.
    2. Ensure initialize() is called before any other SDK methods.
    3. If using RequestConfiguration, bundle it into InitializationConfig.Builder.setRequestConfiguration(). Do not call MobileAds.setRequestConfiguration() before initialization.
  • 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 {} or Dispatchers.Main.launch {} within GMA SDK callbacks. SKIPPING THIS STEP WILL CAUSE THE APPLICATION TO CRASH.
  • Mediation: Classes implementing com.google.android.gms.ads.mediation.Adapter MUST continue using com.google.android.gms.ads.

Format Specifics

Banner Ads

  • Use com.google.android.libraries.ads.mobile.sdk.banner.AdView for loading GMA Next-Gen SDK banners.
  • The following API checks if a banner is collapsible: adView.getBannerAd().isCollapsible().

Native Ads

  • NativeAdLoader: NativeAdLoader is 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: NativeAd no longer has a direct mediaView variable; use registerNativeAd(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... )
Questions fréquentes

Met-il à jour la dépendance du SDK à ma place ?

Oui. Il remplace l'ancienne dépendance Gradle par la dernière version stable de Next-Gen.

Quelles versions d'Android sont requises ?

La liste de contrôle demande un SDK minimum de 24 et un SDK de compilation de 34 ou plus.

Vérifie-t-il que la compilation réussit ?

Oui. Il se termine par une compilation propre pour confirmer que la migration fonctionne.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
22k
Position au classement
#10188
Licence
Apache-2.0
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires