1

I try create admob banner in my app and I get error code 3 please help me to get solution.

I have meta-data in manifest

layout:

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView111"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-9038559490997069/7964491403">
    </com.google.android.gms.ads.AdView>
</LinearLayout>

Java:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    MobileAds.initialize(this, new OnInitializationCompleteListener() {
        @Override
        public void onInitializationComplete(InitializationStatus initializationStatus) {
        }
    });

    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId("ca-app-pub-9038559490997069/7964491403");
    adView = findViewById(R.id.adView111);
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.setAdListener(new com.google.android.gms.ads.AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            Log.e("onAdLoaded","AdLoaded");
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            Log.e("onAdFailedToLoad",""+errorCode);

        }
    });

    adView.loadAd(adRequest);
}

I know have error 3 if admob account is new, I create my admob account before one week.

i get some Logs:

W/FA-Ads: Disabling data collection. Found google_app_id in strings.xml but Google Analytics for Firebase is missing. Remove this value or add Google Analytics for Firebase to resume data collection.2019-12-13 12:06:50.041 6768-6768/myapplication.game D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
I/Ads: Updating ad debug logging enablement.
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/Ads: Use AdRequest.Builder.addTestDevice("94DF0193F80DB5F14BFF0EA958D02BC9") to get test ads on this device.
2019-12-13 12:06:50.248 6768-6768/myapplication.game I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
W/Ads: Update ad debug logging enablement as false
W/Ads: Not retrying to fetch app settings
I/Ads: Ad failed to load : 3
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
gamesgp1
  • 11
  • 1
  • 4

1 Answers1

1

AdMob doesn't allow publishers to load and show real ads while developing. You have to test your ad implementation with test ads either using test ad unit ids or adding your device as a test device. Just don't worry about not loading ads, AdMob doesn't show any ads if your app isn't available on play store. After publishing to the play store AdMob automatically verify your app and start ad serving.

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

change this line with

AdRequest adRequest = new AdRequest.Builder().addTestDevice("94DF0193F80DB5F14BFF0EA958D02BC9").build();

You can get this test device id from logs.