PremiumAds Google AdMob/AdManager Adapter V2 — Flutter
Integrate PremiumAds as a mediation ad source in your Flutter app using Google Mobile Ads Flutter plugin.
Supported formats: Banner, Interstitial, Rewarded, Rewarded Interstitial, Native, App Open
Prerequisites
- Flutter 3.10 or newer (Dart SDK 3.0+)
- google_mobile_ads plugin
- Android
minSdk21+, iOS 13.0+
1. Add the Plugin
Add the PremiumAds adapter to your pubspec.yaml:
dependencies:
google_mobile_ads: ^5.1.0
premium_ads_v2: ^1.0.1
Then run:
flutter pub get
Or install via command line:
flutter pub add premium_ads_v2
Alternative: install from Git
dependencies:
premium_ads_v2:
git:
url: https://github.com/premium-ads/googleads-adapter-v2-flutter.git
2. Native Dependencies (Automatic)
The plugin pulls native binaries automatically — no manual setup needed:
- Android:
net.premiumads.sdk:admob-adapter-v2from PremiumAds JFrog Maven - iOS:
PremiumAdsGoogleAdapterpod from CocoaPods (requires Google Mobile Ads SDK 13.0+)
After flutter pub get, run on iOS:
cd ios && pod install && cd ..
3. Configure AdMob Custom Event
In the AdMob console, configure a Custom Event for each ad unit:
| Platform | Field | Value |
|---|---|---|
| Android | Class Name | net.premiumads.sdk.adapter.PremiumAdsAdapter |
| iOS | Class Name | PremiumAdsAdapter |
| Both | Parameter | Your PremiumAds ad unit ID (e.g. 1234567) |
The same class name works for all ad formats (Banner, Interstitial, Rewarded, Rewarded Interstitial, Native, App Open). The adapter auto-detects the format.
4. Load Ads
The adapter is invoked automatically by Google Mobile Ads SDK — no extra code needed. Use the standard google_mobile_ads API:
import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:premium_ads_v2/premium_ads_v2.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Optional: enable PremiumAds adapter debug logging
await PremiumAdsV2.setDebug(true);
await MobileAds.instance.initialize();
runApp(const MyApp());
}
Banner
final BannerAd bannerAd = BannerAd(
adUnitId: 'ca-app-pub-xxxxx/xxxxx',
size: AdSize.banner,
request: const AdRequest(),
listener: BannerAdListener(
onAdLoaded: (_) => print('Banner loaded'),
onAdFailedToLoad: (_, err) => print('Banner failed: ${err.message}'),
onAdImpression: (_) => print('Banner impression'),
onAdClicked: (_) => print('Banner clicked'),
),
)..load();
// In your widget tree:
SizedBox(
height: bannerAd.size.height.toDouble(),
child: AdWidget(ad: bannerAd),
)
Interstitial
InterstitialAd.load(
adUnitId: 'ca-app-pub-xxxxx/xxxxx',
request: const AdRequest(),
adLoadCallback: InterstitialAdLoadCallback(
onAdLoaded: (ad) {
ad.fullScreenContentCallback = FullScreenContentCallback(
onAdDismissedFullScreenContent: (ad) => ad.dispose(),
);
ad.show();
},
onAdFailedToLoad: (err) => print('Failed: ${err.message}'),
),
);
Rewarded
RewardedAd.load(
adUnitId: 'ca-app-pub-xxxxx/xxxxx',
request: const AdRequest(),
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (ad) {
ad.show(onUserEarnedReward: (_, reward) {
print('Earned ${reward.amount} ${reward.type}');
});
},
onAdFailedToLoad: (err) => print('Failed: ${err.message}'),
),
);
Rewarded Interstitial
RewardedInterstitialAd.load(
adUnitId: 'ca-app-pub-xxxxx/xxxxx',
request: const AdRequest(),
rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
onAdLoaded: (ad) {
ad.show(onUserEarnedReward: (_, reward) {
print('Earned ${reward.amount} ${reward.type}');
});
},
onAdFailedToLoad: (err) => print('Failed: ${err.message}'),
),
);
App Open
AppOpenAd.load(
adUnitId: 'ca-app-pub-xxxxx/xxxxx',
request: const AdRequest(),
adLoadCallback: AppOpenAdLoadCallback(
onAdLoaded: (ad) => ad.show(),
onAdFailedToLoad: (err) => print('Failed: ${err.message}'),
),
);
5. Debug Logging (Optional)
Enable verbose debug logging from the PremiumAds adapter:
import 'package:premium_ads_v2/premium_ads_v2.dart';
await PremiumAdsV2.setDebug(true);
Filter logs:
- Android Logcat:
tag:PremiumAdsAdapter - iOS Xcode console:
[PremiumAdsAdapter]
Example output:
[PremiumAdsAdapter] Debug mode enabled | PremiumAds Adapter v1.0.8
[PremiumAdsAdapter] [Banner] Loading ad with unit: 1234567
[PremiumAdsAdapter] [Banner] Ad loaded successfully
[PremiumAdsAdapter] [Banner] Impression recorded
[PremiumAdsAdapter] [Banner] Click recorded
6. Build & Run
Android
flutter run -d android
iOS
cd ios && pod install && cd ..
flutter run -d ios
Example App
A complete example app with all 6 ad formats is available in the example/ folder of the repository.
Source Code
Troubleshooting
Build fails on iOS with missing PremiumAdsGoogleAdapter:
cd ios && pod install --repo-update
Build fails on Android with missing AAR:
Add the PremiumAds Maven repository to android/build.gradle if not auto-resolved:
allprojects {
repositories {
maven { url 'https://repo.premiumads.net/artifactory/mobile-ads-sdk/' }
}
}
Adapter not initialized: Verify the custom event class name in AdMob console matches exactly:
- Android:
net.premiumads.sdk.adapter.PremiumAdsAdapter - iOS:
PremiumAdsAdapter
Documentation
Support
Contact your PremiumAds account manager or email [email protected]