How to show google Admob Ad on your Android App


If you want to show ad on your android app, best solution is to use Admob ad. Google admob changed their previous ad showing system from august 2014. Now they control their all services from google play service. Google Admob support only support these languages. If you android app is on other language, do not integret admob in your andorid app.

To setup Admob on your android follow this steps =>
1. Open Android SDK Manager. Select Google Play services – Install Packages.



2. File – import- Browse – Select the project of <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/
Then don’t forget to click on the copy project into the workspace. Click on the Finish.


3. Now right click on your project- Properties- on the left side click Android. Then click on the Add. Select google-play-services_lib – Apply.


 4. Next step is create a Ad Space on the Admob. Go to admob and sign up there. You may have to integrate google adsense account. Try to keep your Admob and adsense account on the same google account. After logging click on the Monetize new app- Add your manualy- Write your android app name – Select the platform android. On the next step add the ad unit name and save it.


You will get a Ad unit Id. something like it ca-app-pub-1505016XXXXXXXXXXXX. Remember it. we need it later.
5. Supppose you want to show your ad on the main layout. Check on this commit. add this bold code on the onCreate function.
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);
}

6. on the activity_main.xml, add this code carefully. Here i have added ad unit ca-app-pub-1505016XXXXXXXXXXXX. You can see here demo code.
<com.google.android.gms.ads.AdView
android:id=”@+id/adView”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
ads:adSize=”BANNER”
ads:adUnitId=”ca-app-pub-1505016XXXXXXXXXXXX”
android:layout_alignParentBottom=”true”
android:layout_alignParentLeft=”true”
android:layout_alignParentStart=”true”>
</com.google.android.gms.ads.AdView>

7.  Add this code on your project’s proguard-project.txt file. Source code.
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

8. add this two codes. One is to get full access of user’s internet connection. Another is to support google play services. Here is the source code. First code you have to input between the manifest tag. Another code you have to input between the Application tag.
<uses-permission android:name=”android.permission.INTERNET”/>
<uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE”/>
Another is
<meta-data android:name=”com.google.android.gms.version”
android:value=”@integer/google_play_services_version” />

9.  Compile the code and run it on your device. before running don’t forget to on the internet connection. You can see Ad on your android app. Don’t click it. Google does not like spam click. If anyone click on this ad, this ad will open using google play service.

Hope using this process you have sucessfully integrate admob ad on your android app.


Comments

  1. If you're looking for a good contextual advertising network, I recommend that you have a look at ExoClick.

    ReplyDelete
  2. We have in the organization for a couple of years and have been accomplishment in creating applications distinctively to overall scope of ventures.website

    ReplyDelete
  3. Thus, with wide presence and popularity of Android app businesses having an application on Android platform can widen their business reach and eventually find prospective customers.
    more info

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular Posts

Install and configure Network simulator (ns3) on Ubuntu 14.04