Monday, November 24, 2014

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.


11 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. However, the device has not been fully exposed but the rear panel of the device looks very similar to the Nexus 7 (2013). But the phone is smaller in size, and is undeniably not a device that has been officially launched yet.SuperSU Zip

    ReplyDelete
  5. Now they control their all services from google play service.www.iphonetrackingapps.com

    ReplyDelete
  6. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work Download Towelroot

    ReplyDelete
  7. This basic reason gives you an advantage of controlling this negativism in your kid. The Text Spy app has been recommended by many crime experts because in this manner, many criminals fail to lure your child. mobile phone monitoring review

    ReplyDelete
  8. The worth of Android Smartphone's is flourishing, screen additional than 50,000 Android applications for already specious. prompter

    ReplyDelete
  9. The Mobile application improvement in India has turned into a genuine business as there is a developing inclination to create and outline mobile applications. ZArchiver download

    ReplyDelete
  10. Wonderful post.This is really one of the most beneficial blogs . I am very glad to read such a great blog and thank you for sharing this good information with us. Appvn Apk

    ReplyDelete
  11. One of the most popular cell phones models available on the market is Google's Android phone.https://www.oukitelcentral.com/

    ReplyDelete