Wednesday, January 28, 2009

AdMob for Android Quick start guide


While we wait for the Android Market to support paid apps, AdMob have come out with a product for Android that allows developers to get paid for putting ads in their apps. Below is a quick start guide for now to include AdMob ads into your app.

As suggested in the AdMob blog announcement sign up, fill in all the forms and finally download the SDK. 

Add the following permissions to your AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

Add your publisher id (you can find this under Sites & Apps) inside the application tag of AndroidManifest.xml

  <application>
............
<meta-data android:value="xxxxxxxxxxx" android:name="ADMOB_PUBLISHER_ID" />
............
    </application>

Place the AdMob SDK jar file (currently admob-sdk-1.0-android.jar) into a lib folder in your project
Add the ad view to your layouts
 
  <com.admob.android.ads.AdView  
          android:id="@+id/ad" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content"
  android:layout_alignParentTop="true"           
        />


3 comments:

Phill said...

Hey, thanks for the help on the setup but I've got some problems...

If i try and switch to the layout of my main.xml I get a nullpointerexception?

When I run the app on the emulator, it shows up fine, all works, but no ad unit? Any pointers would be great.

Al said...

I can't get anything to show up. All I get is a blank area where the ad should be?

droidhead68 said...
This comment has been removed by the author.