-2

I have added all required code but admob ad is not visible neither on emulator nor on my device. I have created Admob account today itself, is it the reason why i am not able to see add? The ad part is completely blank while running the app.

AdRequest request = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
            .addTestDevice("MyDeviceId_1").addTestDevice("MyDeviceId")  // An example device ID
            .build();

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<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>

admin 7798
  • 697
  • 1
  • 7
  • 15
  • apply width as match_parent, if still not visible try giving heigh as 50dp. Where have you assigned ad id to admob request? – Harin Dec 31 '15 at 08:47

3 Answers3

1

remove these lines from your root layout

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"

if your AdView will not get full width of your screen, it will not be visible

Also you need to load ad in your AdView

adView.loadAd(request);

check this

Community
  • 1
  • 1
Ravi
  • 34,851
  • 21
  • 122
  • 183
1

For load & show the Admob banner add need to more space .Don't get more space to show on Admob banner add for declaration your root layout(RelativeLayout).Please remove those two line..

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"

Must be you need to add this line on your java code.

adView.loadAd(request);

I don't able to show this line on your code.Are you add this line.Please check this.

Prosanto
  • 914
  • 3
  • 15
  • 27
-1

Be sure to add Internet permission to your manifest. Check RRR's answer too.