Now fisrt time I'm try to use AdMob ads on my Android App.
I follow All documentation of google and try to Implement Admob Banner and InterstitialAd.
I use Test app id & unit id but every time onAdFailedToLoad(ERROR_CODE_NO_FILL) listener call.
I follow all google documentation but then also for both Admob Banner and InterstitialAd why return ERROR_CODE_NO_FILL error?
Please Look my Code:
// ----------------------------- Main Activity -----------------------------------MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
AdView adView = findViewById(R.id.adView2);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
adView.setAdListener(new AdListener(){
@Override
public void onAdLoaded() {
Toast.makeText(MainActivity.this, "Ad Load", Toast.LENGTH_SHORT).show();
super.onAdLoaded();
}
@Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
Toast.makeText(MainActivity.this, "Ad Failed "+ i, Toast.LENGTH_SHORT).show();
}
});
// --------------------------------- Xml --------------------------------
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"/>
// --------------------------------- Meta Data ---------------------------
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
// -------------------------------- Permission -------------------------
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>