How to implement Admob AdView in Android app

Download the AdMob jar file http://www.admob.com/my_sites/

Create a package on your project and call it "libs" and paste this file AdMob.jar there

Right click on your project a select the library, add there the path for the ADMOB.jar you just saved.

If you're creating your AdView on your XML, you can add this line.

This is an example for testing. When you get your own ID from ADMob, place it on the adUnitID and erase the test line.

 com.google.ads.AdView

    android:id="@+id/adView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    ads:adSize="BANNER"
    ads:adUnitId="a14f59e5c442767"
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
    ads:loadAdOnCreate="true"

</com.google.ads.AdView>

Now go to your .java that it calling this layout and create your AdView

AdView adView = (AdView)this.findViewById(R.id.adView1);
adView.loadAd(new AdRequest());

This is how I do and its been working good so far.

Sorry about bad english, to much code and no sleep!


just follow the instructions on this site: http://developer.admob.com/wiki/Android#AdMob_Android_SDK

I guess you did not activate the test mode for your device or the emulator?!

AdManager.setTestDevices( new String[] {                 
   AdManager.TEST_EMULATOR,             // Android emulator
   "E83D20734F72FB3108F104ABC0FFC738",  // My T-Mobile G1 Test Phone
} );  

It seems as though this might have changed to

AdRequest request = new AdRequest();
request.addTestDevice(AdRequest.TEST_EMULATOR);
request.addTestDevice("E83D20734F72FB3108F104ABC0FFC738"); // My T-Mobile G1 test phone

see http://code.google.com/mobile/ads/docs/android/intermediate.html

As per Tom's comment below the value to provide for addTestDevice is actually the MD5 hash of the device ID. YOu can get this from the logcat.