Adding Google Admob Module to Titanium Appcelerator

Posted by Will on February 20, 2013

Sometimes the simplest things just don’t have the proper documentation and I noticed a lack of information on doing something as simple as implementing the AdMob module in Appcelerator. This is one of the first tasks I did when starting to learn Appcelerator, and while simple enough, involves a couple of different steps to make sure everything is working ok.

Add the Module

Download the AdMob module. You must login to download, but its free and there’s no catch. The current module page says it’s only compatible through Titanium 2.0, but I have confirmed it is working properly in 3.0. Unzip and put the module files in the correct folder. In OSX that folder is /Library/Application Support/Titanium/Modules/. In Windows it should be in a folder like C:\Users\\AppData\Roaming\Titanium\modules. Place either the iphone or android or both folders into the previously mentioned folders.

Open up your tiapp.xml file and edit the source of it. Look for the modules xml specification. Within the tag you would add the following line:
Please keep in mind that this current version is 1.3, and its important that you update the version number here if a newer version is out.

Making the view

The documentation provided with the admob module is enough to figure things out. What it doesn’t tell you is that in addition to the custom variables, it allows the common ui/positioning variables so that you can properly place your add. Also, you must have both the height and width specified for the ad view, or an ad probably won’t load. For the iPhone, that ad size is 320×50. For Android, I believe it varies. Below is the code I use to add an add to my iPhone application. The ad in this case touches the bottom of the screen, and I have passed the keyword sports in order to hopefully get more relevant ads returned back from AdMob. I created the ad view as follows…

var admob = require('ti.admob');

var adView = admob.createView({
	publisherId: 'YOURIDHERE',
	adBackgroundColor: '#666666',
	keywords: 'sports',
	bottom: 0,
	width: 320,
	height: 50,


As you can see its about as simple as creating any other view. Make sure you add that first line, as its necessary to require the module files.

If the module won’t load or an error is returned…

When dealing with new modules, one of the most common problems I’ve found is the necessity to clear your build folder. So, if you’re having problems, try deleting the build folder’s contents and rebuilding the project.

Leave a Reply

Your email address will not be published. Required fields are marked *