我正在尝试实施AdMob标语广告。测试ID工作正常。但是对于我的广告ID,它显示了在logcat下发布错误。
维护性
MobileAds.initialize(this, "MY_APP_ID");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
XML
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="MY_AD_ID" />
清单
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="MY_APP_ID"/>
PROJECT.GRADLE
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
APP.GRADLE
implementation 'com.google.android.gms:play-services-ads:15.0.1'
LOGCAT
10-10 15:47:21.430 29883-30587 /?电子广告:等待未来时出错。 java.util.concurrent.ExecutionException:java.util.concurrent.TimeoutException com.google.android.gms.ads.internal.util.future.af.get(:com.google.android.gms @ 14366007 @ 14.3.66(020304-213742215):18) com.google.android.gms.ads.internal.util.future.g.a(:com.google.android.gms @ 14366007 @ 14.3.66(020304-213742215):11) com.google.android.gms.ads.internal.request.service.c.a(:com.google.android.gms @ 14366007 @ 14.3.66(020304-213742215):36) com.google.android.gms.ads.internal.request.service.c.a(:com.google.android.gms @ 14366007 @ 14.3.66(020304-213742215):169) com.google.android.gms.ads.internal.request.service.f.run(:com.google.android.gms @ 14366007 @ 14.3.66(020304-213742215):1) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:422) 在java.util.concurrent.FutureTask.run(FutureTask.java:237) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587) 在java.lang.Thread.run(Thread.java:818) 造成原因:java.util.concurrent.TimeoutException com.google.android.gms.ads.internal.util.future.m.run(未知来源) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:422) 在java.util.concurrent.FutureTask.run(FutureTask.java:237) 在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:152) 在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587) 在java.lang.Thread.run(Thread.java:818) 10-10 15:47:22.280 13964-13979 / com.ashleytobeybuttons.whosyourdaddyboy I /广告:广告服务器未填充。 10-10 15:47:22.300 13964-13964 / com.ashleytobeybuttons.whosyourdaddyboy W / Ads:无法加载广告:3