我已将来自 firebase 的原生 express adview 添加到我的应用程序中 当我使用他们提供的测试 ID 时它加载正常,但是当我用我的发布者 ID 和单元 ID 替换它时,它停止显示它
日志猫
Starting ad request.
Use AdRequest.Builder.addTestDevice("3C5C50F4B6108021A73AB0588B9E62C0") to get test ads on this device.
There was a problem getting an ad response. ErrorCode: 0
Failed to load ad: 0
Ad is not visible. Not refreshing ad.
Scheduling ad refresh 60000 milliseconds from now.
代码 XML
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/adView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center_horizontal|center"
ads:adSize="FULL_WIDTHx80"
ads:adUnitId="@string/ad_unit_id">
</com.google.android.gms.ads.NativeExpressAdView>
Java
MobileAds.initialize(getApplicationContext(), APIClass.PUBLISHER_ID);
NativeExpressAdView adView = (NativeExpressAdView) findViewById(R.id.adView1);
adView.loadAd(new AdRequest.Builder().build());
当我添加将应用发布到 Play 商店时,广告会显示吗
最佳答案
With Native Ads Express, your NativeExpressAdView size needs to fit in the range of sizes you picked in the AdMob Front-end. In this case, Smart banner is not big enough.
See the Choosing a Size section in the docs for what the ranges are for the Native Ads Express templates. Now see how the sizing of Native Ads Express works, since you chose SMART_BANNER as your size (FULL_WIDTHx80).
Let's say you're running this app on a Nexus 5 in portrait. The smart banner will be sized at
360x50
. When you compare that against the requirements for the Native Ads Express templates, you'll see that even the Small template requires a height of 80dp. Because your size doesn't fit the requirements, you won't ever see an ad.Try changing the size to ads:adSize="300x250". That size fits all 3 templates, and so you should get an ad back. I just tested it myself and it worked for your ad unit. For more precise measurements, double check which size you picked on the AdMob front-end, and make sure the width and height of your ad fits within the ranges.
We'll investigate more internally why the error code indicates internal error. This could be surfaced a bit better. However, I'm going to close this issue though for the reasons mentioned above.
回答自 here
关于android - Native Express AdView 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38035088/