Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob giving me ErrorCode: 1

Tags:

android

admob

W/Ads: There was a problem getting an ad response. ErrorCode: 1
W/Ads: Failed to load ad: 1

From logcat,

This is my code in Activity:

MobileAds.initialize(getApplicationContext(), "ca-app-pub-6122511777440087~4654564876");
        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();

        mAdView.loadAd(adRequest);

And layout:

<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_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="@string/banner_ad_unit_id">
        </com.google.android.gms.ads.AdView>

Lastly my string resource:

<string name="banner_ad_unit_id">ca-app-pub-6122511777440087~4654564876</string>

What gives? I even tried a test ad and that didn't work. Same error code and same failure to load ad.

like image 639
AeriaGlorisia Avatar asked Feb 05 '23 20:02

AeriaGlorisia


1 Answers

app id and app unit id should be different. in your code seems to be same

here is full official description: https://firebase.google.com/docs/admob/android/quick-start

like image 178
Jaydeep Devda Avatar answered Feb 07 '23 11:02

Jaydeep Devda