AdMob real ads are not showing, only test ads are displayed

▼魔方 西西 提交于 2019-12-12 10:57:03

问题


I have tested the ad feature on my phone. Only the test ad are show. When I replace the unit id with my which I got from AdMob, the real ads are not displayed.

What is the problem?

Here is my code:

 <string name="banner_ad_unit_id">ca-app-pub-11*************1/7********5</string>

for xml i used

  <com.google.android.gms.ads.AdView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            ads:adSize="BANNER"
            android:id="@+id/adView"
            ads:adUnitId="@string/banner_ad_unit_id">
        </com.google.android.gms.ads.AdView>

for loading ad i used

     AdView adView=(AdView)findViewById(R.id.adView);
    AdRequest adRequest= new AdRequest.Builder().setRequestAgent("android_studio:ad_template").build();

    adView.loadAd(adRequest);

In manifeast I have

    <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

. . .

  <activity android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
       android:theme="@android:style/Theme.Translucent"/>

But my ads do not load in the android device. Test ads are working fine. I used a real device for all of these operation. Any help please?


回答1:


Okay the things are right as far as I see here. You donot necessarily need that templete way as mention above.

The ads are not showing because you may just have registered for ads. Your ad registeration should first be verified in google servers and that service should be activated and verified properly so that the request is not made from autoPrograms. So you should wait for at least 1-2 hours. Regards.




回答2:


The issue is with your AdRequest.

Change:

AdRequest adRequest = new AdRequest.Builder().setRequestAgent("android_studio:ad_template").build();

to:

AdRequest adRequest = new AdRequest.Builder().build();

Google APIs for Android: AdRequest.Builder setRequestAgent



来源:https://stackoverflow.com/questions/43374698/admob-real-ads-are-not-showing-only-test-ads-are-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!