-2

Hey Guys I am using "Google Play Services" to integrate AdMobs banners ads in my application. In Eclips the ads looks fine but when I try to run the application it doesn't show ads in real device. Here is the XML Code I am using for ads.

I am not using any Java code for ads. Just using this XML code provided here. (https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration)

  <com.google.android.gms.ads.AdView 
      android:id="@+id/adView"
      ads:adSize="BANNER"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      ads:adUnitId="ca-app-pub-5278017493272368/8871679336"/>

Here is the Screenshot of the ads showing in Eclips.

Ads In Eclips are displayed Like this

Please help me to solve this problem. Any Help will be Appreciated.

Thanls.

Sikandar Ejaz
  • 53
  • 3
  • 9

1 Answers1

2

You have to load it.

Try adding xmlns attribute.

<com.google.android.gms.ads.AdView 
  xmlns:ads="http://schemas.android.com/apk/res-auto"
  android:id="@+id/adView"
  ads:adSize="BANNER"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  ads:adUnitId="ca-app-pub-5278017493272368/8871679336"/>

in onCreate event add this code:

AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);

Hope it helps...

okkko
  • 1,010
  • 1
  • 13
  • 22
  • added this in code, but now getting error in Main ACtivity. 1-AdRequest.Builder cannot be resolved to a type. 2- The method loadAd(AdRequest) in the type AdView is not applicable for the arguments (AdRequest) NOw what do you say? – Sikandar Ejaz Oct 26 '14 at 08:35
  • Using the search function I got this: http://stackoverflow.com/questions/20607746/adrequest-builder-cannot-be-resolved-to-a-type – okkko Oct 26 '14 at 08:43