我正在尝试在我的Android应用中实施亚马逊广告,但无法展示任何广告。我的日志中的消息始终是:
D/AmazonMobileAds DefaultAdListener: Default ad listener called - Ad Failed to Load. Error code: NO_FILL, Error Message: Server Message: no results
我已经设置了帐户,验证了我的税务信息,我有一个应用程序密钥。我已尝试使用测试启用和禁用相同的结果。我已按照指南从亚马逊和Admob加载广告进行补余,但此后也无法检索AdMob广告。如果我只检索AdMob广告,我对它们没有任何问题。相关代码如下:
onCreate()中的:
AdRegistration.setAppKey(getString(R.string.amazon_ad_id));
AdRegistration.enableTesting(true);
AdRegistration.enableLogging(true);
// Initialize ad views
amazonAdView = new com.amazon.device.ads.AdLayout(this);
amazonAdView.setListener(new MyAdListener());
admobAdView = new com.google.android.gms.ads.AdView(this);
admobAdView.setAdSize(com.google.android.gms.ads.AdSize.SMART_BANNER);
admobAdView.setAdUnitId(getString(R.string.banner_ad_unit_id));
要求检索广告的方法:
void getAd(){
// Initialize view container
adViewContainer = (ViewGroup)findViewById(R.id.adView);
amazonAdEnabled = true;
adViewContainer.removeAllViews();
adViewContainer.addView(amazonAdView);
AdTargetingOptions adOptions = new AdTargetingOptions();
adOptions.enableGeoLocation(true);
amazonAdView.loadAd(adOptions);
}
内部AdListener类
class MyAdListener extends DefaultAdListener {
public void onAdLoaded(com.amazon.device.ads.AdLayout view, AdProperties adProperties) {
Log.d(LOG_TAG, "Ad Loaded");
if (!amazonAdEnabled) {
amazonAdEnabled = true;
adViewContainer.removeView(admobAdView);
adViewContainer.addView(amazonAdView);
}
}
public void onAdFailedToLoad(com.amazon.device.ads.AdLayout view, AdError error) {
Log.d(LOG_TAG, "Ad Failed to load");
// Call AdMob SDK for backfill
if (amazonAdEnabled) {
amazonAdEnabled = false;
adViewContainer.removeView(amazonAdView);
adViewContainer.addView(admobAdView);
}
admobAdView.loadAd((new com.google.android.gms.ads.AdRequest.Builder()).build());
}
}
在我的日志记录中,AdListener的所有语句都没有显示,因此似乎永远不会调用侦听器。所以,我在这里有两个问题:
为什么即使在测试时我也总是收到NO_FILL响应?
为什么听众从不打电话?