I am trying to add google native ads in my flutter app using this library

https://pub.dev/packages/google_mobile_ads

i am getting this error:

\[log\] NativeAd failed to load: LoadAdError(code: 0, domain: com.google.android.gms.ads, message: Internal error., responseInfo: ResponseInfo(responseId: _-SvZbabD5e-3LUP4oaxkAs, mediationAdapterClassName: , adapterResponses: \[AdapterResponseInfo(adapterClassName: com.google.ads.mediation.admob.AdMobAdapter, latencyMillis: 83, description: { "Adapter": "com.google.ads.mediation.admob.AdMobAdapter", "Latency": 83, "Ad Source Name": "Reservation campaign", "Ad Source ID": "7068401028668408324", "Ad Source Instance Name": "\[DevRel\] \[DO NOT EDIT\] Native Ads Campaign", "Ad Source Instance ID": "3518433842871043", "Credentials": { "pubid": "ca-app-pub-3940256099942544/2247696110/cak=no_cache&cadc=c3&caqid=_-SvZfiWDr-FmsMPtMWtgAM", "campaign_id": "12584073087" }, "Ad Error": { "Code": 0, "Message": "Internal error.", "Domain": "com.google.android.gms.ads", "Cause": "null" } }, adUnitMapping: {pubid: ca-app-pub-3940256099942544/2247696110/cak=no_cache&cadc=c3&caqid=\_-SvZfiWDr-FmsMPtMWtgAM, campaign_id: 12584073087}, adError: AdError(code: 0, domain: com.google.android.gms.ads, message: Internal error.), adSourceName: Reservation campaign, adSourceId: 7068401028668408324, adSourceInstanceName: \[DevRel\] \[DO NOT EDIT\] Native Ads Campaign, adSourceInstanceId: 3518433842871043)\], loadedAdapterResponseInfo: null), responseExtras: {mediation_group_name: Campaign}) 

Minimal Code to Reproduce

Native Controller:

import 'package:get/get.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; class NativeAdController extends GetxController{   NativeAd? ad;   final adLoaded = false.obs; } 

Ad Helper:

import 'dart:developer'; import 'package:flutter/foundation.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import '../controllers/controller_native_ads.dart'; class AdHelper{   static Future<void> initAds() async {     await MobileAds.instance.initialize();   }   void loadInterstitialAd({required VoidCallback onComplete}) {     InterstitialAd.load(       adUnitId: 'ca-app-pub-3940256099942544/1033173712',       request: const AdRequest(),       adLoadCallback: InterstitialAdLoadCallback(         // Called when an ad is successfully received.         onAdLoaded: (ad) {           ad.fullScreenContentCallback = FullScreenContentCallback(             onAdDismissedFullScreenContent: (ad) {               onComplete();             },             onAdFailedToShowFullScreenContent: (ad, error) {               log(error.toString());             },             onAdShowedFullScreenContent: (ad) {               log("Full Screen");             },           );           log('This is the $ad loaded.');         },         // Called when an ad request failed.         onAdFailedToLoad: (LoadAdError error) {           log('InterstitialAd failed to load: $error');         },       ),     );   }   static NativeAd loadNativeAd({required NativeAdController nativeAdController}) {     return NativeAd(       adUnitId: 'ca-app-pub-3940256099942544/2247696110',       listener: NativeAdListener(         onAdLoaded: (ad) {           log('$NativeAd loaded.');           nativeAdController.adLoaded.value = true;         },         onAdFailedToLoad: (ad, error) {           log('$NativeAd failed to load: $error');           ad.dispose();         },       ),       request: const AdRequest(),       // Styling       nativeTemplateStyle: NativeTemplateStyle(         templateType: TemplateType.small,       ),     )..load();   } } 

Test Screen:

import 'package:flutter/material.dart'; import '../controllers/controller_native_ads.dart'; class TestScreen extends StatelessWidget{   TestScreen({super.key});   final adController = Get.put(NativeAdController());   @override   Widget build(BuildContext context) {     adController.ad = AdHelper.loadNativeAd(nativeAdController: adController);     return Scaffold(       bottomNavigationBar: adController.ad != null && adController.adLoaded.isTrue           ? SafeArea(               child: SizedBox(                 height: 80,                 child: AdWidget(ad: adController.ad!),               ),             )           : null,     );   } } 

I am using test id provided by official google docs flutter-quick-start

Can anyone explain me why this error occurs?

Tag:google-ads-api, admob, flutter, firebase, dart

Add a new comment.