I tried for hours to set Admob in my application but I'm getting the error code 3. here are the steps I followed :
In the admob interface I clicked on 'monetize a new app' then 'Add an application manually'
For the application's name I put the same in the manifest :
android:label="NameApp"
- Then I choose the ads' type (banner)
Then admob ask for the package's name I put the 'applicationID' attribute available in the gradle file
I obtained an ID. I put this id here :
<string name="banner_ad_unit_id">ca-app-pubXXXXXX-XXX</string>
And to finish, I use this code :
MobileAds.initialize(this.getContext(), getString(R.string.banner_ad_unit_id)); AdView mAdView = (AdView) v.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest);
In XML :
<com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="@string/banner_ad_unit_id" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="25dp"> </com.google.android.gms.ads.AdView>
And when i run the app. I obtain 'Failed to load ad: 3'. Note that when I use the banner in test mode it works. I think that the error is in the package's name.