How to integrate new Admob ad Banner in Android Project using Google Play Services Library.

As we know On August 1, 2014, Google Play will stop accepting new or updated apps that use the old standalone Google Mobile Ads SDK v6.4.1 or lower. So you must upgrade to the Google Play version of the Mobile Ads SDK.
Here are the simple steps to integrate it.

Click Here to Download Source file of this project.

Required steps before you start:

1. Get admob ad unit Publisher id from your admob account.
2. Import "google-play-services_lib" Library to your eclipse.

You will find "google-play-services_lib" Library in "..\adt-bundle-windows-x86_64-20130917\sdk\extras\google\google_play_services\libproject" Path.
Copy this "google-play-services_lib" Library to your Eclipse workspace then Import it to eclipse.

Step 1:

Right click on your project then go to properties. Click on "Android". In that window under library click on "Add" button then Select "google-play-services_lib" and click on ok.

Step 2:

Open "AndroidMenifest.xml". Copy and paste these two permissions above "application" tag.



Add this meta tag inside "application" tag.


Add this Activity "application" tag.



Your AndroidManifest.xml will look like:



    

    
    

    
        
            
                

                
            
        
        
        

        
    


Step 3:

Open "activity_main.xml". Copy and paste

xmlns:ads="http://schemas.android.com/apk/res-auto"

under "xmlns:android="http://schemas.android.com/apk/res/android" Line.

Copy and paste


Inside your layout.

Now, your activity_main.xml will look like:


    
    


Step 4:

Open "MainActivity.java". Import

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

then copy and paste this code inside onCreate Method

AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);

now, your "MainActivity.java" will look like:

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);
  
 }

 
}

Save and run your project :)



Click Here to Download Source file of this project.

If you face any problem do comment.

Thank you.

Comments

  1. why u don't create mig33 pc soft again :( i like your soft.tsunami v4.flood 1 by 1.amazing.tq boss

    ReplyDelete
  2. Thank you very much

    ReplyDelete
  3. Help please!!!
    does not work in PreferenceActivity....

    ReplyDelete
    Replies
    1. please show me your code or more details about the problem you getting :)

      Delete
  4. I corrected.
    Thank you!

    ReplyDelete
  5. And thank you for tutorial.

    ReplyDelete

Post a Comment

Popular posts from this blog

Android Sudoku Game Project With Source Code