How to make money from your FREE Android App
Previously I have posted the step-by-step how-to related to AdMob SDK 4.x in your Android apps in this post http://blog.kerul.net/2011/05/installing-google-admob-into-android.html . This time is the AdMob 6.0 SDK released just recently. There’s one think I don’t like about the tutorial in the official documentation, the example only demonstrate an app with only one widget, which is the AdView widget (read here if u’d like to know what I mean https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals). Practically that doesn’t happen, coz normally we have several other widgets in the screen.
//this is the simplified versions of the codes below.
1. Download and admob sdk - in libs folder. Set path to the external library
2. admob layout
3. add control in Java src
private AdView adView;
adView = (AdView)findViewById(R.id.ad);
4. AndroidManifext.xml - add add this activity declaration inside <application></application>
5. AndroidManifext.xml - additional permissions
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
STEP 1: Register yourself as a user at http://admob.com . Login and create a site (read further at http://blog.kerul.net/2011/05/installing-google-admob-into-android.html)
If you do not have a new site, than add one.
Scroll down and fill-up your app information. Leave the Android package URL blank if you have not upload your app yet.
Opt for typical ad banner 350x50 – later we can change into smart_banner option. Change the refresh rate if you’d like to.
Check the Ad Network should you have the account for the ad provider.
Save it and you’ll get the next screen. Notice the mediation ID (or Publisher ID), this ID will be needed in the in the AdView widget later.
STEP 2: Download the AdMob SDK currently SDK 6.1.0 at https://developers.google.com/mobile-ads-sdk/download#downloadandroid
Extract the zip file downloaded and you will get a file named GoogleAdMobAdsSdk-6.1.0.jar.
You may copy the file to be pasted in the project folder later.
STEP 3: Add an External JAR (library) in the project.
In your Android project create another directory called libs in your project. Notice the name, it will be used later as the path to you additional XML scheme in the apps view. (more on creating a new Android project in Eclipse –> http://blog.kerul.net/2011/06/creating-new-android-project-in-eclipse.html)
Copy GoogleAdMobAdsSdk-6.1.0.jar into libs
Create the new folder libs by right-click on your project->New->Folder. Copy the GoogleAdMobAdsSdk-6.1.0.jar into the libs folder.
Adding an additional library
Click on the project you’re currently working, hit Project->Properties on the Eclipse menu. Click on the Java build path as in the Fig 9, and hit Add External JARs button.
Locate the GoogleAdMobAdsSdk-6.1.0.jar file in the workspace/project/libs .
And you’ll see the GoogleAdMobAdsSdk-6.1.0.jar in the libs folder, as in Fig 11.
STEP 4: Additional details in the AndroidManifest.xml
Open your AndroidManifest.xml using the code editor, and add this lines to the <application> properties;
And the meta-data attributes;
And the complete AndroidManifest.xml;
STEP 5: Adding the AdView widget in the screen
For example, your app view (screen) is the res/layout/main.xml, open this in the code editor.
Add a TableRow (optional) in the existing layout as a place to contain the AdView widget.
- Put the adMob XML schema in the AdView widget. notice the path apk/lib/com.google.ads in line 6. APK is your app, LIB is the from the folder LIBS we jest created in the STEP 3 and COM.GOOGLE.ADS refering to the one of the component in the JAR file GoogleAdMobAdsSdk-6.1.0.jar .
- ads:adSize="SMART_BANNER" – in line 10 is referring to the banner size. During my testing on the tablet, this adSize is suitable because it does expand base on screen size.
- Change to your publisher ID (or Mediation ID) in line 11.
And the complete main.xml file would be;
STEP 6: Adding the adView in the source code.
In your existing Activity class (where you wanna display the adMob), add the following lines; line 7, line 15 and 16.
Compile and run in your emulator.
Testing the app with AdMob – the application is available here - http://bit.ly/pbahasa
Or download the APK here http://bit.ly/peribahasa-apk and follow this tutorial to install the APK into your emulator –> http://blog.kerul.net/2012/08/how-to-install-apk-files-on-android.html .
Hopefully you get the idea. All the best for the experiment…