I am attempting to place an AdMob banner at the bottom of my page, but the Ad is not appearing. There seems to be space allocated for it, but the AdMob banner is not displaying.
- Include and reference the Google Play services library. - CONFIRMED
- Add a meta-data tag in AndroidManifest.xml. - CONFIRMED
- Declare com.google.android.gms.ads.AdActivity in the manifest. - CONFIRMED
- Configure network permissions in the manifest. - CONFIRMED
If anyone can provide insight into why the AdMob banner is not showing, I would greatly appreciate it.
Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/flContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ad_layout"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/ad_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:orientation="vertical" />
</RelativeLayout>
Here is the MainActivity.java code:
// Create an ad.
adView = new AdView(context);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
// Add the AdView to the view hierarchy.
LinearLayout layout = (LinearLayout) findViewById(R.id.ad_layout);
layout.addView(adView);
// Create an ad request.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE").build();
// Start loading the ad in the background.
adView.loadAd(adRequest);