I had a YouTube comment a while back ask me for the source code to one of my games, simply so that he could figure out how to add AdMob ads to his own game. For some programmers out there, the real barrier of entry to market seems to be a lack of knowledge on how to add AdMob and Adsense to your application, and how to publish it on the Android Market. It can be a bit of a pain, but once you’ve got it down it’s a straightforward process. I’ve written a detailed tutorial for those who’d rather not have to figure all this out from scratch.
Read on for the full 25 step guide to adding ads and publishing your Android app to market.
- Step 1 is, of course, to actually write an Android app. Check out my YouTube channel for a nice video to help you along with that.
- Write out a nice description for your app in a word processor. No spelling mistakes! You’ll paste this description all over, so make sure it’s good.
- Register a new android app on admob.com. You’ll need the description you wrote above.
- On the AdMob site, set admob.com->app name->app settings->google adsense to TRUE. I also like to set a 60 second ad refresh timeout.
- Before exiting AdMob, copy out the publisher ID for this particular Android app. It’ll be a long hash string on the top of the page when you click on the program details in your dashboard.
- Open Eclipse (or your editor of choice), and open up your Android project directory.
- Make sure your Manifest file has your correct project name i.e. com.hunterdavis.easycatwhistle. One accepted general format is com.publisher.program.
- Ensure the Manifest file has correct permissions for and file or hardware access and specifies a minimum api level (I generally use 7 or above)
- The ads will be dynamic, so also ensure your Manifest has network access permissions
- Add your AdMob activity line into your Manifest file. It will be of the form
< activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation" / >
- In your main.xml file (and any other layouts you wish to have ads in), paste in your adsense xlns namespace. It’ll look like:
- In your main.xml file (and any other layouts you wish to have ads in), paste in your adsense resource id and widget code. It’ll look like:
< com.google.ads.AdView android:id="@+id/adView" android:layout_alignParentTop="true" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adUnitId="YOURIDHERE" ads:adSize="BANNER" ads:loadAdOnCreate="false" / >
- In your activities java file, add an ad network request during your activities oncreate function. It’ll look like
AdView adView = (AdView) this.findViewById(R.id.adView); adView.loadAd(new AdRequest());
- Open up your favorite editor and create a 512×512 PNG hires image. Draw what you like, as it’ll be the icon for your program. I like to save it into a “deploy” folder as icon.png
- Now you need to generate the 3 levels of icon files Android requires. You can either do this manually, or have http://www.androidicongenerator.net do it for you. Save each of these 3 icons generated into the res folder (high medium and low), replacing the default icon.png files that get generated by the SDK.
- Copy the description of your app from above into a blog post or permalink page. You can use this as the website link during the publishing step.
- Execute your app in a high-res emulator (like the 800×600 one that comes with the SDK), and take two Screenshots of your app. (Camera button on device menu in Eclipse)
- Upload these screenshots to the blog post or permalink page you created earlier.
- Use the Android tools menu in Eclipse (or the SDK command line tools, etc) to generate a signed application package. It’ll require that you type in your publisher name and location, as well as set a password for your encryption.
- *Optional – Test your signed application package on a real live device. I use swiftp on the Android, filezilla on the PC, and easy file manager on the Android. Upload the package to somewhere you can browse to it on your Android device over ftp (or USB or whatever) and ensure your program looks good with ads and rotation etc.
- Upload the signed package, icon, screenshots, and fancy description to the Android market and click publish.
- Find your Market page, it’ll be of the form
- Link to your market page from your blog post or permalink page.
- Post your market page, blog post, or permalink page to Facebook, Reddit, Hacker News, Google+, what have you!