Firebase Admob广告即使在一个月后仍未展示,因此无法加载

时间:2020-10-31 04:17:47

标签: firebase flutter admob

我正在尝试将Firebase Admob实施到我的应用中,并且尝试使用横幅广告,这些广告在使用测试ID时显示,但在使用真实应用ID时不显示。我等待了大约一个月,仍然没有广告。 我按照他们的指示阅读了所有文档,但还是没有运气 错误日志显示广告无法加载3 不知道是什么原因造成的。 谢谢。

      class ImagePath extends StatefulWidget {
        final String imgPath;
        ImagePath(this.imgPath);
        @override
        _ImagePathState createState() => _ImagePathState();
      }

      class _ImagePathState extends State<ImagePath> {
        String localPath;

        static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
          testDevices: testDevice != null ? <String>[testDevice] : null,
          nonPersonalizedAds: true,
          keywords: ["website", "games"],
        );

        BannerAd bannerAd;
        BannerAd createBannerAd() {
          return BannerAd(
              adUnitId: "AD-ID-HERE",
              size: AdSize.banner,
              targetingInfo: targetingInfo,
              listener: (MobileAdEvent event) {
                print("BannerAd $event");
              });
        }

        @override
        void initState() {
          FirebaseAdMob.instance
              .initialize(appId: "APP-ID-HERE");
          bannerAd = createBannerAd()
            ..load()
            ..show(anchorType: AnchorType.bottom);
          super.initState();
        }

        @override
        void dispose() {
          bannerAd?.dispose();
          super.dispose();
        }

        Future<String> get localpath async {
          final result = await Permission.storage.request();
          if (result == PermissionStatus.granted) {
            final localPath =
                (await findLocalPath()) + Platform.pathSeparator + 'Download';
            final savedDir = Directory(localPath);
            bool hasExisted = await savedDir.exists();
            if (!hasExisted) {
              savedDir.create();
            }
            return localPath;
          } else
            return null;
        }

        Future<String> findLocalPath() async {
          final directory = Platform.isAndroid
              ? await getExternalStorageDirectory()
              : await getApplicationDocumentsDirectory();
          return directory.path;
        }

        @override
        Widget build(BuildContext context) {
          return Scaffold(
            appBar: AppBar(
              backgroundColor: bgColor,
              leading: IconButton(
                icon: Icon(Icons.close),
                onPressed: () => Navigator.of(context).pop(),
                color: Colors.white,
              ),
              actions: [
                IconButton(
                    color: Colors.white,
                    icon: Icon(Icons.file_download),
                    onPressed: () async => DownloadTask(
                        taskId: await FlutterDownloader.enqueue(
                            url: widget.imgPath,
                            savedDir: await localpath,
                            showNotification: true,
                            openFileFromNotification: true)))
              ],
            ),
            body: SizedBox.expand(
              child: Container(
                child: Stack(
                  children: [
                    Align(
                      alignment: Alignment.center,
                      child: Hero(
                          tag: widget.imgPath, child: Image.network(widget.imgPath)),
                    ),
                  ],
                ),
              ),
            ),
            backgroundColor: bgColor,
          );
        }
      }

错误日志-

             D/ActivityThread(29222): holder:android.app.IActivityManager$ContentProviderHolder@c4e7070, holder.provider:android.content.ContentProviderProxy@a482fe9
            D/DynamitePackage(29222): Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
            I/WebViewFactory(29222): Loading com.google.android.webview version 86.0.4240.110 (code 424011000)
            W/ResourceType(29222): Found multiple library tables, ignoring...
            I/System  (29222): FinalizerDaemon: finalize objects = 289
            D/WebView (29222): WebView<init>
            I/cr_LibraryLoader(29222): Loaded native library version number "86.0.4240.110"
            I/cr_CachingUmaRecorder(29222): Flushed 5 samples from 5 histograms.
            E/chromium(29222): [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/sagarrawatuk.fotoApp/cache/WebView/Crashpad: No such file or directory (2)
            D/ConnectivityManager.CallbackHandler(29222): CM callback handler got msg 524290
            D/WebView (29222): addJavascriptInterface=googleAdsJsInterface
            D/WebView (29222): removeJavascriptInterface=accessibility
            D/WebView (29222): removeJavascriptInterface=accessibilityTraversal
            D/WebView (29222): loadUrl=https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html
            W/cr_media(29222): Requires BLUETOOTH permission
            V/SettingsInterface(29222): invalidate [secure]: current 2 != cached 0
            E/libEGL  (29222): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
            D/ActivityThread(29222): holder:android.app.IActivityManager$ContentProviderHolder@90636e7, holder.provider:android.content.ContentProviderProxy@a09f294
            D/DynamitePackage(29222): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
            D/SettingsInterface(29222):  from settings cache , name = android_id , value = e6623267e10d401e
            I/Ads     (29222): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("0D97118CC9A4746D5FDA6A253D5479F1") to get test ads on this device.
            D/MPlugin (29222): createInstance(): Begin = 485050486
            D/MPlugin (29222): create Instance (two parameters) with : com.mediatek.common.telephony.IOnlyOwnerSimSupport
            D/MPlugin (29222): Clazz exists on mapping table : false
            E/MPlugin (29222): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport
            D/MPlugin (29222): createInstance(): End = 485050486
            I/DynamiteModule(29222): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:203404601
            I/DynamiteModule(29222): Selected remote version of com.google.android.gms.ads.dynamite, version >= 203404601
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_enabled , value = 0
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_font_scale , value = null
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_locale , value = null
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_preset , value = null
            D/libc-netbsd(29222): [getaddrinfo]: hostname=googleads.g.doubleclick.net; servname=(null); netid=0; mark=0
            D/libc-netbsd(29222): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
            W/Ads     (29222): Not retrying to fetch app settings
            D/libc-netbsd(29222): getaddrinfo: googleads.g.doubleclick.net get result from proxy gai_error = 0
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_enabled , value = 0
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_font_scale , value = null
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_locale , value = null
            D/SettingsInterface(29222):  from settings cache , name = accessibility_captioning_preset , value = null
            D/libc-netbsd(29222): [getaddrinfo]: hostname=googleads.g.doubleclick.net; servname=(null); netid=0; mark=0
            D/libc-netbsd(29222): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
            W/Ads     (29222): Not retrying to fetch app settings
            D/libc-netbsd(29222): getaddrinfo: googleads.g.doubleclick.net get result from proxy gai_error = 0
            D/OpenSSLLib(29222): OpensslErr:Module:12(116:176); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object
            D/OpenSSLLib(29222): OpensslErr:Module:12(116:176); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object
            W/flutter (29222): onAdFailedToLoad: 3
            I/Ads     (29222): Ad failed to load : 3
            I/flutter (29222): BannerAd MobileAdEvent.failedToLoad
            D/SQLiteDatabase(29222): beginTransaction()
            D/SQLiteDatabase(29222): endTransaction()
            D/SQLiteDatabase(29222): beginTransaction()
            D/SQLiteDatabase(29222): endTransaction()
            D/WebView (29222): evaluateJavascript=(function(){})()
            D/WebView (29222): evaluateJavascript=google.afma.config.fetchAppSettings({"id":"1728bed4-cfbf-449f-a186-a71cd6e27ce4","args":{"app_id":"APP_ID","is_init":true,"pn":"sagarrawatuk.fotoApp"}});

1 个答案:

答案 0 :(得分:0)

您是否在Admob帐户中设置了付款明细?提供付款明细后,大约需要一天时间才能在您的应用上展示广告。