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
| Requirement | Version |
|---|---|
| Cocos Creator | 3.7.3+ (tested 3.8.x) |
cocos/cocos-google-admob extension | latest from Cocos Store |
Android minSdk | 21 |
| iOS deployment target | 13.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:
- Open Cocos Dashboard → Extensions → search
Google AdMob. - Install the Google AdMob for Cocos Creator extension into your project.
- 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'sassets/- Contains
PremiumAdsAdapter.ts(TS plugin: optionalsetDebug()helper)
- Contains
native/engine/android/→ your project'snative/engine/android/build.gradleinjects the adapter v2 + JFrog Maven repo + GMA SDK depAndroidManifest.xmlinjects the AdMob app-id meta-data + AdActivity + permissionssrc/net/premiumads/cocos2dx/PremiumAdsAdapterBridge.java— JNI peer
native/engine/ios/→ your project'snative/engine/ios/Podfile.ininjects the adapter pod + GMA podInfo.plist.ininjectsGADApplicationIdentifier+ SKAdNetwork list + ATT descriptionClasses/PACPremiumAdsAdapter.{h,mm}— Obj-C++ peer (Swift bridging viaPremiumAdsGoogleAdapter-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:
| Field | Value |
|---|---|
| Class name (Android) | net.premiumads.sdk.adapter.PremiumAdsAdapter |
| Class name (iOS) | PremiumAdsAdapter |
| Parameter | PremiumAds Adunit |
| eCPM | start 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:
- Project → Build → Android (or iOS)
- Select platform options, click Build
- 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.setDebugdoes nothing on web/preview: expected.jsb.reflection.callStaticMethodonly exists on Android/iOS native builds. Test on a device.- Adapter never appears in
MobileAds.initializeadapter map: confirm the AAR/Pod is actually linked (./gradlew :app:dependencies | grep premium,pod list | grep PremiumAds). cocos-google-admobextension 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