Android Admob setup - Android Developement
When you are working on developing your own applications for mobile phones, it is good to monetize them to generate income out of it. Admob is very useful for this purpose both in Android development and iOS development. This tutorial is for showing how to setup the admob for android applications.
First step in doing that is to create an account at Admob to get your Admob publisher ID.
Once you receive your Admob ID, proceed with the below steps for setup.
Open your AndroidManifest.xml file and add a new activity for google AdActivity as shown in the below code.
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|smallestScreenSize|uiMode|screenSize"/>
It is very important that the android:configChanges should have all the values shown above. If you miss any value, it may result in a error such as "You must have AdActivity declared in AndroidManifest.xml with config changes".
next step is to change your main activity xml where you want to have the ad to be shown. Add the below code as shown.
<com.google.ads.AdView xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/adView1" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="a14f260c8b212d0" ads:adSize="BANNER" ads:loadAdOnCreate="true"/>
I am currently using GoogleAdmobSDK of 4.3.1 version and able to run the ads successfully using the build target as Android-13 and with miniSDKVersion as 7.
If you encounter any errors, look at the LogCat to identify the real cause.
I hope this article is helpful to you.
More by this Author
Spring framework provides different ways to authenticating a user against a LDAP either through spring LDAP templates or through spring security. Here I explained how to authenticate the user using the spring ldap...