Flutter Firebase Admob广告失败

问题描述

  • 我已经验证了Admob ac。
  • 我使用keytool -genkey -v -keystore c:\ Users \ USER_NAME \ key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key创建了密钥
  • 我创建了firebase ac并连接了应用,firebase批准了通讯,但仍然显示广告错误

Ad failed to load : 3

在AdvertClass中

import 'dart:io';

class AdvertService {
  static final AdvertService _instance = AdvertService._internal();
  factory AdvertService() => _instance;
  MobileAdtargetingInfo _targetingInfo;
  final String _bannerAd = Platform.isAndroid
      ? 'ca-app-pub-6xxxxxxxxx01/xxxxxx5'
      : 'ca-app-pub-67xxxxxxxx01/2xxxxxx';

  AdvertService._internal() {
                                                      //USB cabled android,got that id with adb devices
    _targetingInfo = MobileAdtargetingInfo( testDevices: <String>["54a0a4f2"]);
  }
  showBanner() {
    print(_bannerAd);
    BannerAd banner = BannerAd(
        adUnitId: _bannerAd,size: AdSize.smartBanner,targetingInfo: _targetingInfo);

    banner
      ..load()
      ..show();
    banner.dispose();
  }
}

解决方法

没问题,您必须等待。

The ad request was successful,but no ad was returned due to lack of ad inventory. 您可以阅读文档:https://developers.google.com/android/reference/com/google/android/gms/ads/AdRequest#ERROR_CODE_NO_FILL