I am following this tutorial on Firebase, adding AdMob in our app. I did whatever was written.
XML :
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
Activity :
private AdView mAdView;
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
String :
<string name="banner_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/6300978111</string>
I am getting this message :
09-02 02:04:53.088 26922-26939/com.arqamahmad.languageslearnandtalk W/Ads: There was a problem getting an ad response. ErrorCode: 0
09-02 02:04:53.118 26922-26922/com.arqamahmad.languageslearnandtalk W/Ads: Failed to load ad: 0
Then I registered the application in AdMob, went through the steps.
But I am not seeing real time ads in the banner instead I am seeing the text shown by Firebase on the banner.
So how can we get real time ads on the banner.
PS : This is my practice app and not in the play store. Just in my personal device.
答案 0 :(得分:2)
ca-app-pub-3940256099942544/6300978111是测试广告单元ID。将其替换为您应用的广告单元ID。
还将java更改为
MobileAds.initialize(getApplicationContext(), "ca-app-pub-XXXXXXXXX/XXXXXXXX");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest);
将您下载的google-service.json文件复制到项目的根文件夹中。