广告加载失败
Ads failing to load
Starting ad request.
09-16 09:31:56.827 9836-9836/com.netvariant.panic I/Ads: Use
AdRequest.Builder.addTestDevice("F92724BDB6A4403A8C027B851F7DA3AF")
to get test ads on this device.
09-16 09:31:58.385 9836-9849/com.netvariant.panic I/Ads: No fill
from ad server.
09-16 09:31:58.392 9836-9836/com.netvariant.panic W/Ads: Failed to load ad: 3
我在 xml 中遇到此错误:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/tesd"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.doubleclick.PublisherAdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-4532549351948034/7622739505" />
</RelativeLayout>
我的 java 代码是:
mAdView = (PublisherAdView) rootView.findViewById(R.id.ad_view);
// Create an ad request. Check logcat output for the hashed
device ID to
// get test ads on a physical device. e.g.
// "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to
get test ads on this device."
PublisherAdRequest adRequest = new
PublisherAdRequest.Builder().build();
// Start loading the ad in the background.
mAdView.loadAd(adRequest);
这就是加载它的方式。问题是什么?感谢 You.I 使用我的 Mac sha1(不是我用来在商店上传的密钥库)创建了 firebase 和 admob 帐户。am 运行 从我的 android 工作室到设备,它不是 working.I 在我的应用程序中也有 google-services.json。
我遵循了这个说明
[https://firebase.google.com/docs/admob/][1]
如 logcat 控制台中所述,您需要将以下行添加到启动广告的代码块中。
AdRequest.Builder.addTestDevice("F92724BDB6A4403A8C027B851F7DA3AF");
这有助于 Google Ads 知道您正在模拟器上测试广告功能并 return 测试广告。这样做的原因是为了确保开发人员在测试时不会(意外地)点击广告,这可能会导致您的广告帐户被禁止,而且,实际设备上的其他应用 运行 会投放真实广告.
Starting ad request. 09-16 09:31:56.827 9836-9836/com.netvariant.panic I/Ads: Use AdRequest.Builder.addTestDevice("F92724BDB6A4403A8C027B851F7DA3AF") to get test ads on this device. 09-16 09:31:58.385 9836-9849/com.netvariant.panic I/Ads: No fill from ad server. 09-16 09:31:58.392 9836-9836/com.netvariant.panic W/Ads: Failed to load ad: 3
我在 xml 中遇到此错误:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/tesd" android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.gms.ads.doubleclick.PublisherAdView android:id="@+id/ad_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-4532549351948034/7622739505" /> </RelativeLayout>
我的 java 代码是:
mAdView = (PublisherAdView) rootView.findViewById(R.id.ad_view); // Create an ad request. Check logcat output for the hashed device ID to // get test ads on a physical device. e.g. // "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device." PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); // Start loading the ad in the background. mAdView.loadAd(adRequest);
这就是加载它的方式。问题是什么?感谢 You.I 使用我的 Mac sha1(不是我用来在商店上传的密钥库)创建了 firebase 和 admob 帐户。am 运行 从我的 android 工作室到设备,它不是 working.I 在我的应用程序中也有 google-services.json。
我遵循了这个说明
[https://firebase.google.com/docs/admob/][1]
如 logcat 控制台中所述,您需要将以下行添加到启动广告的代码块中。
AdRequest.Builder.addTestDevice("F92724BDB6A4403A8C027B851F7DA3AF");
这有助于 Google Ads 知道您正在模拟器上测试广告功能并 return 测试广告。这样做的原因是为了确保开发人员在测试时不会(意外地)点击广告,这可能会导致您的广告帐户被禁止,而且,实际设备上的其他应用 运行 会投放真实广告.