Admob 加载广告失败:0
Admob Failed to load ad: 0
我大约在 12 小时前创建了我的 adMob 广告单元并按如下方式实施:
XML:
<com.google.android.gms.ads.AdView
android:id="@+id/bannerAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-9378881698271837/3415450508">
</com.google.android.gms.ads.AdView>
MainActivity.java:
bannerAd = (AdView) findViewById(R.id.bannerAdView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(MY_DEVICE_ID).build();
bannerAd.loadAd(adRequest);
Gradle 依赖关系:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-ads:11.0.1'
compile 'com.google.android.gms:play-services-ads:11.0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
testCompile 'junit:junit:4.12'
}
清单权限:
<uses-permission android:name="android.permission.INTERNET" />
我遵循了 Firebase 和 adMob 集成文档,但它不会在我 运行 应用程序所在的任何设备上显示广告。
如果您使用 firebase 连接,那么还要添加 maven{url "https://maven.google.com"}在项目模块 gradle 中,并在 admob 帐户中添加付款明细
我大约在 12 小时前创建了我的 adMob 广告单元并按如下方式实施:
XML:
<com.google.android.gms.ads.AdView
android:id="@+id/bannerAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-9378881698271837/3415450508">
</com.google.android.gms.ads.AdView>
MainActivity.java:
bannerAd = (AdView) findViewById(R.id.bannerAdView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(MY_DEVICE_ID).build();
bannerAd.loadAd(adRequest);
Gradle 依赖关系:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-ads:11.0.1'
compile 'com.google.android.gms:play-services-ads:11.0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
testCompile 'junit:junit:4.12'
}
清单权限:
<uses-permission android:name="android.permission.INTERNET" />
我遵循了 Firebase 和 adMob 集成文档,但它不会在我 运行 应用程序所在的任何设备上显示广告。
如果您使用 firebase 连接,那么还要添加 maven{url "https://maven.google.com"}在项目模块 gradle 中,并在 admob 帐户中添加付款明细