What are the exact steps to add AdMob to my app?

edited October 8 in Android Mode

Hello all!

I am new to coding, been only doing it daily for a month or two, and I just finished my first game for android. I would like to add it to the Google Play Store with AdMob. I have registered for AdMob, and now I need to incorporate the ads to my code, however, I have no idea how to do that.

I already saw https://forum.processing.org/two/discussion/16686/how-to-add-admob and I read through all of it twice, but am still completely at a loss. The topic is really messy and riddled with trials and errors, and has code and symbols that I have never used nor understood at all, making its contents practically unreadable for someone with as little coding experience as me. What is a manifest? What's a .jar file, why do I need it and where do I get it?

I put so much effort into my game and I am so eager to see it in the store, but I just can't get past this final step.

If some kind soul could give me and, likely, the thousands of other newcomers looking for an answer, a step-by-step walkthrough of exactly what I need to download, where I need to download it, and provide an organized snippet of code that I can adapt for my program, words can't describe how grateful I would be.

Thank you all in advance!



  • edited October 5


    This is the default AdMob guide that I have gone through but also don't understand as it's made for Android Developer Studio.

  • "The topic is really messy and riddled with trials and errors, and has code and symbols that I have never used nor understood at all, making its contents practically unreadable for someone with as little coding experience as me."

    Welcome to programming.

  • edited October 8 Answer ✓


    • first step: get your Ad unit id from your admob account; it should be something like ca-app-pub-(+ a lot of numbers); if only for testing use the ad unit id given by Google: ca-app-pub-3940256099942544~3347511713; then choose a format among the 3 provided: as for now choose "banner" which is the more simple.

    • second step: use the code i have already given and that i give again:

                  import android.os.Looper;//for setup() if needed
                  import android.os.Bundle;
                  import android.view.Window;
                  import android.widget.RelativeLayout;
                  import android.app.Activity;
                //  import com.google.ads.*;//
                  import com.google.android.gms.ads.AdRequest;
                  import com.google.android.gms.ads.AdView;
                  import com.google.android.gms.ads.AdSize;
                  import com.google.android.gms.ads.MobileAds;
                  public void setup(){
                    size(800, 1000);
                  public void draw(){
                  @ Override
                  public void onCreate(Bundle savedInstanceState) {
                  //here you get the window
                  Window window = getActivity().getWindow();
                  //here you add a layout to your window; working with AS or Eclipse you can skip that because you can modify the xml; with processing you have to do that by code
                   RelativeLayout adsLayout = new RelativeLayout(this.getActivity());
                  //here you set the params for your layout
                   RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
                      RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
                  // now you create your View
                  AdView adView = new AdView(this.getActivity());
                  // here you add the view to the layout and build your AdRequest
                      AdRequest newAdReq = new AdRequest.Builder()
            // .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)//
             //  .addTestDevice("xxxxxxxxxxxxxxxxx")// this is the id  from your phone for testing; you can get it using TelephonyManager
                  ///and finally ad the whole stuff to your window
    • step 3: modify your Manifest a) adding permissions:::

                   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
                    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
                    <uses-permission android:name="android.permission.INTERNET"/>
                    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
                    <uses-permission android:name="android.permission.SET_ORIENTATION"/>
                                            b) adding metadata for your com.google.android.gms.version: this is the number corresponding to the version you want the client-user have : of course if it is not installed or if it s too old your app will not run; here you can write with some lines a method for checking the client phone and open a dialog asking for updating or installing;

    all these details are explained in the link you posted in this forum and you can find an example i have given for the Manifest;

    • step 4: verify that googlePlayServices is installed in your SDK (SDK menu, Extras)

    • step 5: try and see wether the imports can be solved; if not (that was the case in the discussion you have seen) get the .jar from the url i have given in the same discussion, create a folder "code" in your sketch and add the .jar. When you download it it is a .zip and its name contains the version number you have to write in your Manifest.

  • @akenaton THANK YOU!

    Where in my code should I place the manifest?

  • @randomdude===

    you have only to edit the Manifest; nothing to do (in this case) by code.

  • Ooh I see.

    And does it matter where in the manifest I add these permissions (start, middle, end)?

  • edited October 8

    No need to modify the manifest directly. Instead, if you are using Processing, go to the Android in the menu bar and click on sketch permissions. There you can check the permission you want to enable. This action will update your manifest for you.

    ***Edit: Here I am only referring to permissions btw.


  • @kfrajer===

    you are right for permissions, but in this case it s necessary to edit the manifest in order to add (metadata) the com.google.android.gms.version required.

  • I can't compose the metadata on my own. Is it too much to ask to give a bit more detailed explanation on how to add metadata?

  • edited October 8


    yes that is possible:: see the link you posted here and see my manifest example... and be conscious that you ask for things rather complicated && know nothing about android

  • @akenaton

    I don't just know nothing about Android - I basically know nothing about coding altogether.

    I started merely a month ago. But I am a quick learner and have gotten pretty far already, relying (and owing) only to experienced programmers like you who are willing to help.

    I don't know what I can do to show my gratitude for your help. It is in my nature to want to know more, so I will probably keep asking rather complicated things. If you think I know too little to achieve the things I want to achieve, you don't have to bother to answer. However, so far I have been able to grasp everything I ask about if somebody provides a good description.

    AdMob is clear to me now and has been successfully implemented in my code.


  • @randomdude===

    be happy when coding! but think= learning is for each day!

  • @randomdude===

    && never think that you "KNOW"

  • @akenaton

    I am having tremendous fun while coding, that is why I am so eager to get better -- FASTER. I have so many ideas that I want to see come to life!! I just need the experience and knowledge. And I can acquire experience and knowledge much more efficiently by relying on others sharing theirs with me.

    "If I have seen further it is by standing on the shoulders of giants." -Isaac Newton

Sign In or Register to comment.