Java / Android Developer, Trainer, Writer, Speaker

Monday, November 10, 2014

Like the article?

Well! Hello Android Developers! It’s been amazing what Google doing since its birth! But, it’s also some kind of pain to cope up with its updates and newer things. It’s been painful for some people to set up new Admob for PhoneGap in new updated system. Previously we used to use an Admob jar file, but now system has been changed.  We’ll see this today. The developers who are from web developing background loves to code work with PhoneGap for Android Application development.

For the post, the first recommendation is reading this post: Google Play New Android SDK Setup for AdMob ( AdSense )

In this post I’ll just show the code placement along with file placement. PhoneGap files placement steps:

Step 1: Place cordova.js file in your project folder > assets > www > from workspace.

Step 2: Place XML folder to your project folder > res from workspace.

If you don’t know what I’m talking about, or what is cordova.js file / xml folder, please follow this:

Read More: 9 Ideas for Career ( Online Money Making ) based on your Love

Now, The code placement steps:

Step 1: First of all, place the below code in import section, for PhoneGap cordova:

import org.apache.cordova.DroidGap;

Step 2: We need more importing for AdMob Advertisement. Place the below codes in import section too:


Step 3: Now rename this line ‘public class Second extends Activity ‘ to ‘public class MainActivity extends DroidGap ‘ for using Phonegap

Step 4: Now declare a private variable ‘private AdView adView;’ just before onCreate method.

Step 5: Into onCreate method place this line   super.loadUrl("file:///android_asset/www/index.html"); right after super.onCreate(savedInstanceState);

Step 6: Make the onCreate Method public from protected.

Step 7: Now, place the below codes into onCreate method.

            // Create the adView. [ ]

            adView = new AdView(this);



            LinearLayout layout = super.root;


            //  [ ]

            AdRequest request = new AdRequest.Builder()



            //  [ ]

            // Start loading the ad in the background.


Replace setAdUnitID with your Ad Code.

We are done! Now you can compile and see output. If you are not clear yet, you can follow the below image.

admob ad placement in phonegap for android

After successful placement, Admob add will appear like below image. I took a screenshot for you guys.

PhoneGap Admob add

Read More: R cannot be resolved to a variable error in Android Development and Solution

I hope you did it successfully, leave a comment if you face any problem. Share this post for others then others will share something good for you too. Subscribe for more.

Read More: Career in Mobile Application Development for You : My Experience


  1. eToro is the ultimate forex broker for beginner and pro traders.

  2. You can make $20 for each 20 minute survey!

    Guess what? This is exactly what large companies are paying for. They need to know what their customer needs and wants. So large companies pay $1,000,000's of dollars per month to the average person. In return, the average person, like me, participates in surveys and gives them their opinion.

  3. Considering to join new affiliate programs?
    Visit this affiliate directory to see the ultimate list of affiliate programs.

  4. Quantum Binary Signals

    Professional trading signals sent to your mobile phone daily.

    Start following our signals NOW and earn up to 270% a day.

  5. If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you gotta watch this video
    right away...

    (VIDEO) Get your ex back with TEXT messages?