Pages

Sunday, February 2, 2014

Android: How to add Ads in your Android App

These are few steps showing how you can add admob ads to your android applications.
First create an admob account in http://www.google.com/ads/admob/  or if you already have an admob account, login to your account.
Give all the payment information and then select Sites & Apps tab .Click Add Sites/App, now select Android App

and fill all the informations including App name, Android Package Url and click Continue.

Click on the link "See developer's guide, examples, and FAQ at Google Code" and open it in a new tab.

Click Download Admob Android SDK button, extract the file and copy the sdk jar file,GoogleAdMobAdsSdk-6.4.1.jar to projects lib folder in eclipse.
Right click the Project and select properties. Choose Java Build Path and add the downloaded external sdk jar file.
Now go to the page "see developer's guide", which is already opened in a new tab. Goto "Defining a com.google.ads.AdView" section and copy the code marked in red rectangle box below,

and paste it into your activity.xml file and save it.

Go back to admob website and click "Goto Sites/Apps" button
Here you see you App name listed, click Manage Settings .

A publisher Id will be displayed in next window. Copy the Publisher id and paste it into the
activity.xml file





Next we need to copy some codes to AndroidManifest.xml file. For that again go back to page that we opened in the new tab,"See developer's guide" page.
At the end of the page just above the "The Result" section click on the download example project.

Extract the downloaded file and open the BannerXML folder and open the AndroidManifest.xml file using a text editor and copy the below code to your AndroidManifest file in your project.

Save your project and run as android application. Ads will now show up in your android app.

1 comment: