Skip to main content
Version: v2.0

PremiumAds Google AdMob Adapter V2 — Cocos Creator

Integrate PremiumAds as a mediation ad source in your Cocos Creator (TypeScript) game. Cocos Creator 3.7.3+ uses the official Google AdMob for Cocos Creator extension to load ads; the PremiumAds adapter sits behind it as an AdMob mediation custom event — your TS code continues to call the AdMob extension API, AdMob's waterfall picks PremiumAds when configured.

Supported formats: Banner, Interstitial, Rewarded, Rewarded Interstitial, Native, App Open

Reference repo: premium-ads/googleads-adapter-v2-cocos-creator — TypeScript plugin + sample scene + native bridges, ready to drop into a Cocos Creator project.

Prerequisites

RequirementVersion
Cocos Creator3.7.3+ (tested 3.8.x)
cocos/cocos-google-admob extensionlatest from Cocos Store
Android minSdk21
iOS deployment target13.0+
Google Mobile Ads SDK (Android)play-services-ads:23.6.0+ (auto-injected by extension)
Google Mobile Ads SDK (iOS)Google-Mobile-Ads-SDK ~> 13.0 (auto-injected by extension)

1. Install the Cocos AdMob Extension

The PremiumAds adapter is a mediation provider for Google's AdMob, so your project needs a working AdMob integration first. Cocos Creator ships an official extension:

  1. Open Cocos DashboardExtensions → search Google AdMob.
  2. Install the Google AdMob for Cocos Creator extension into your project.
  3. Restart the editor when prompted.

Documentation for the extension: <https://github.com/cocos/cocos-google-admob>

2. Copy the PremiumAds Plugin

From the reference repo, copy:

  • assets/PremiumAdsAdapter/ → your project's assets/
    • Contains PremiumAdsAdapter.ts (TS plugin: optional setDebug() helper)
  • native/engine/android/ → your project's native/engine/android/
    • build.gradle injects the adapter v2 + JFrog Maven repo + GMA SDK dep
    • AndroidManifest.xml injects the AdMob app-id meta-data + AdActivity + permissions
    • src/net/premiumads/cocos2dx/PremiumAdsAdapterBridge.java — JNI peer
  • native/engine/ios/ → your project's native/engine/ios/
    • Podfile.in injects the adapter pod + GMA pod
    • Info.plist.in injects GADApplicationIdentifier + SKAdNetwork list + ATT description
    • Classes/PACPremiumAdsAdapter.{h,mm} — Obj-C++ peer (Swift bridging via PremiumAdsGoogleAdapter-Swift.h)

Cocos Creator's native build system merges these template files into the generated Android Studio / Xcode project automatically when you run Build → Native in the editor.

3. Set the AdMob App IDs

Edit the values in native/engine/android/AndroidManifest.xml and native/engine/ios/Info.plist.in to your own AdMob app IDs:

<!-- AndroidManifest.xml -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY" />
<!-- Info.plist.in -->
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY</string>

4. Use the API in TypeScript

Optional — turn on verbose adapter logs while testing:

import { PremiumAdsAdapter } from './PremiumAdsAdapter/PremiumAdsAdapter';

PremiumAdsAdapter.setDebug(true);

Logs are tagged [PremiumAdsAdapter] in:

  • Android Logcat: filter tag:PremiumAdsAdapter
  • iOS Xcode console: prefix [PremiumAdsAdapter]

For ad loading, use the Google AdMob for Cocos Creator extension API directly — the PremiumAds adapter is invoked by AdMob's waterfall, not by your TS code:

// Pseudocode — exact API depends on the cocos-google-admob extension version.
// See https://github.com/cocos/cocos-google-admob for current API.
import { Banner, Interstitial, Rewarded } from '@admob';

const ANDROID_BANNER = 'ca-app-pub-XXXXXXXXXXXXXXXX/AAAAAAAAAA';
const IOS_BANNER = 'ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB';

Banner.show(sys.platform === sys.Platform.ANDROID ? ANDROID_BANNER : IOS_BANNER);

Interstitial.load(unitId, () => Interstitial.show());

Rewarded.load(unitId, () => {
Rewarded.show();
});

5. Configure AdMob Custom Event

For each ad unit you want to mediate through PremiumAds, add a custom event in the AdMob console:

FieldValue
Class name (Android)net.premiumads.sdk.adapter.PremiumAdsAdapter
Class name (iOS)PremiumAdsAdapter
ParameterPremiumAds Adunit
eCPMstart at $0.10 to test, then tune

After publishing the mediation change (5–30 min propagation), filter logs for [PremiumAdsAdapter]. If you see the line, the waterfall reached PremiumAds.

6. Build & Run

In Cocos Creator editor:

  1. Project → Build → Android (or iOS)
  2. Select platform options, click Build
  3. After build completes, click Make (Android Studio) or Open in Xcode (iOS) to compile & run on device/emulator

The PremiumAds plugin's native templates are merged automatically — no manual gradle/Podfile edits needed beyond setting your AdMob app IDs in step 3.

Troubleshooting

  • PremiumAdsAdapter.setDebug does nothing on web/preview: expected. jsb.reflection.callStaticMethod only exists on Android/iOS native builds. Test on a device.
  • Adapter never appears in MobileAds.initialize adapter map: confirm the AAR/Pod is actually linked (./gradlew :app:dependencies | grep premium, pod list | grep PremiumAds).
  • cocos-google-admob extension import error: make sure you installed the extension from Cocos Dashboard (not just cloned the repo). After install, restart the editor.

What gets shipped

PremiumAds Cocos Creator integration is mediation custom-event only — your game uses the official cocos-google-admob extension API to load ads. The PremiumAds adapter activates only when AdMob's waterfall picks it for a given ad unit.

Demo project

Clone the reference repo, open in Cocos Creator 3.7.3+:

git clone https://github.com/premium-ads/googleads-adapter-v2-cocos-creator.git
# Open the cloned folder in Cocos Dashboard → Add Project
# Wire up the HelloWorld scene buttons in the Editor
# Project → Build → Android / iOS