-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find an ad network adapter with the name(s): com.google.DummyAdapter. Remember to link all required ad network adapters and SDKs, and set -ObjC in the 'Other Linker Flags' setting of your build target. #363
Comments
Hi @AnhTu6610, Thanks for filing the issue. When filing issues please try to fill some or all of the information requested in the issue template. To investigate the issue further please share the output of |
flutter doctor -v
|
@AnhTu6610 Please make sure you are using the correct ad unit ids does the ad load with test unit ids? |
i am using test unit ids and google_mobile_ads: ^0.13.4 |
Is this issue on Android/ IOS / both? with all types of ads or specific ad? code sampleimport 'dart:io';
import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'reusable_inline_example.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
MobileAds.instance.initialize();
runApp(MyApp());
}
// You can also test with your own ad unit IDs by registering your device as a
// test device. Check the logs for your device's ID value.
const String testDevice = 'YOUR_DEVICE_ID';
const int maxFailedLoadAttempts = 3;
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static final AdRequest request = AdRequest(
keywords: <String>['foo', 'bar'],
contentUrl: 'http://foo.com/bar.html',
nonPersonalizedAds: true,
);
InterstitialAd? _interstitialAd;
int _numInterstitialLoadAttempts = 0;
RewardedAd? _rewardedAd;
int _numRewardedLoadAttempts = 0;
BannerAd? _anchoredBanner;
bool _loadingAnchoredBanner = false;
@override
void initState() {
super.initState();
_createInterstitialAd();
_createRewardedAd();
}
void _createInterstitialAd() {
InterstitialAd.load(
adUnitId: InterstitialAd.testAdUnitId,
request: request,
adLoadCallback: InterstitialAdLoadCallback(
onAdLoaded: (InterstitialAd ad) {
print('$ad loaded');
_interstitialAd = ad;
_numInterstitialLoadAttempts = 0;
_interstitialAd!.setImmersiveMode(true);
},
onAdFailedToLoad: (LoadAdError error) {
print('InterstitialAd failed to load: $error.');
_numInterstitialLoadAttempts += 1;
_interstitialAd = null;
if (_numInterstitialLoadAttempts <= maxFailedLoadAttempts) {
_createInterstitialAd();
}
},
));
}
void _showInterstitialAd() {
if (_interstitialAd == null) {
print('Warning: attempt to show interstitial before loaded.');
return;
}
_interstitialAd!.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: (InterstitialAd ad) =>
print('ad onAdShowedFullScreenContent.'),
onAdDismissedFullScreenContent: (InterstitialAd ad) {
print('$ad onAdDismissedFullScreenContent.');
ad.dispose();
_createInterstitialAd();
},
onAdFailedToShowFullScreenContent: (InterstitialAd ad, AdError error) {
print('$ad onAdFailedToShowFullScreenContent: $error');
ad.dispose();
_createInterstitialAd();
},
);
_interstitialAd!.show();
_interstitialAd = null;
}
void _createRewardedAd() {
RewardedAd.load(
adUnitId: RewardedAd.testAdUnitId,
request: request,
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (RewardedAd ad) {
print('$ad loaded.');
_rewardedAd = ad;
_numRewardedLoadAttempts = 0;
},
onAdFailedToLoad: (LoadAdError error) {
print('RewardedAd failed to load: $error');
_rewardedAd = null;
_numRewardedLoadAttempts += 1;
if (_numRewardedLoadAttempts <= maxFailedLoadAttempts) {
_createRewardedAd();
}
},
));
}
void _showRewardedAd() {
if (_rewardedAd == null) {
print('Warning: attempt to show rewarded before loaded.');
return;
}
_rewardedAd!.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: (RewardedAd ad) =>
print('ad onAdShowedFullScreenContent.'),
onAdDismissedFullScreenContent: (RewardedAd ad) {
print('$ad onAdDismissedFullScreenContent.');
ad.dispose();
_createRewardedAd();
},
onAdFailedToShowFullScreenContent: (RewardedAd ad, AdError error) {
print('$ad onAdFailedToShowFullScreenContent: $error');
ad.dispose();
_createRewardedAd();
},
);
_rewardedAd!.setImmersiveMode(true);
_rewardedAd!.show(onUserEarnedReward: (RewardedAd ad, RewardItem reward) {
print('$ad with reward $RewardItem(${reward.amount}, ${reward.type}');
});
_rewardedAd = null;
}
Future<void> _createAnchoredBanner(BuildContext context) async {
final AnchoredAdaptiveBannerAdSize? size =
await AdSize.getAnchoredAdaptiveBannerAdSize(
Orientation.portrait,
MediaQuery.of(context).size.width.truncate(),
);
if (size == null) {
print('Unable to get height of anchored banner.');
return;
}
final BannerAd banner = BannerAd(
size: size,
request: request,
adUnitId: Platform.isAndroid
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716',
listener: BannerAdListener(
onAdLoaded: (Ad ad) {
print('$BannerAd loaded.');
setState(() {
_anchoredBanner = ad as BannerAd?;
});
},
onAdFailedToLoad: (Ad ad, LoadAdError error) {
print('$BannerAd failedToLoad: $error');
ad.dispose();
},
onAdOpened: (Ad ad) => print('$BannerAd onAdOpened.'),
onAdClosed: (Ad ad) => print('$BannerAd onAdClosed.'),
),
);
return banner.load();
}
@override
void dispose() {
super.dispose();
_interstitialAd?.dispose();
_rewardedAd?.dispose();
_anchoredBanner?.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(builder: (BuildContext context) {
if (!_loadingAnchoredBanner) {
_loadingAnchoredBanner = true;
_createAnchoredBanner(context);
}
return Scaffold(
appBar: AppBar(
title: const Text('AdMob Plugin example app'),
actions: <Widget>[
PopupMenuButton<String>(
onSelected: (String result) {
switch (result) {
case 'InterstitialAd':
_showInterstitialAd();
break;
case 'RewardedAd':
_showRewardedAd();
break;
default:
throw AssertionError('unexpected button: $result');
}
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: '$InterstitialAd',
child: Text('$InterstitialAd'),
),
PopupMenuItem<String>(
value: '$RewardedAd',
child: Text('$RewardedAd'),
),
],
),
],
),
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
if (_anchoredBanner != null)
Container(
color: Colors.green,
width: _anchoredBanner!.size.width.toDouble(),
height: _anchoredBanner!.size.height.toDouble(),
child: AdWidget(ad: _anchoredBanner!),
),
],
),
),
);
}),
);
}
}
|
i use ad unit ids it works, but using test unit ids it doesn't work. Only error on ios |
@AnhTu6610, please share a reproducible code sample or a git repo to further investigate the issue. And also which IOS device are you having issues with? |
Having same issue with test ad unit ids |
Exactly the same here. I have the interstitials working but the banner ones launch this error 😢 In addition, just in case, I added |
I can't reproduce the issue the interstitial and banner ads both work fine for me with test Ids. cc: @jjliu15 |
Hello @maheshmnj! In case you need, I could do a call to showcase the issue :) |
@rocboronat, sure please that would be much helpful. |
@maheshmnj I'll drop you a line on Twitter 🐦 |
Ohh, sorry I did not construe it as an actual call, Probably that's not required, you could just share more details here in the thread so that it helps the team members working on this issue.
Thanks |
Same situation here, any solution? |
Using iOS 15 simulator. Flutter sdk: '>=2.12.0 <3.0.0'
google_mobile_ads: 0.13.5
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
http: 0.13.3
share: 2.0.4
transparent_image: 2.0.0
url_launcher: 6.0.11
fluro: 2.0.3
flutter_launcher_icons: 0.9.2
cupertino_icons: 1.0.3
google_mobile_ads: 0.13.5
firebase_messaging: 10.0.7
shared_preferences: 2.0.8
fluttertoast: 8.0.8
glassmorphism: 3.0.0
flutter_blurhash: 0.6.0
sortedmap: 0.5.1
json_annotation: 4.1.0
flutter_card_swipper: 0.4.0
scrollable_positioned_list: 0.2.0-nullsafety.0
youtube_player_iframe: ^2.2.2
shimmer: 2.0.0
cached_network_image: ^3.1.0 |
For me is working on Android but not on iOS |
@AnhTu6610 is this issue resolved? |
I still have this issue with version 1.0.1. |
I think its good to leave this issue open until we are sure that this is fixed. |
I'm getting this error as well. No Ads are shown. If I change the Bundle Identifier in xcode (ie: by adding a 1 at the end) and run the project ads are shown. |
pod 'Google-Mobile-Ads-SDK' Xcode -Version 12.4 (12D4e) I'm having this issue with banner ad testAdID units when rotating on an iPad to landscape.
The odd thing is once I rotate back to portrait the ad appears. This process is non-stop. The ad always shows in portrait but nothing shows in landscape with the same above error message I looked in code:
|
Answer to my issue is here. I just had to use my real ad unit id for it work |
I was using the real ad unit all the time and also getting this issue on published app
This issue was created almost 4 months ago. Any solution so far? This is showing no ads for me on iOS |
I had the same problem. I found this thread while googling a solution. Basically the information of the site below helped a lot. you have 2 options.
Im using swift, so i added Swift part to AppDelegate as below (be sure that the serial number that you got in the log is set as testDeviceIdentifier and not the number im writing in this example )
Finally, be sure you have all the ad networks are set (Info.plist in my case). This document tells you how to do it |
We’re closing this issue due to inactivity. If you’re still impacted, please create a new issue via the Developer Forum. |
The text was updated successfully, but these errors were encountered: