This guide is for developers who are interested in making money using advertisements. Use this guide to understand how to use AdMob to add advertisements in Android applications
Step 1:
Copy and past Admob ad SDK in Project libs Folder.
Step 2:
Right Click the Project then select project properties
Step 3:
Selected Java Build path –> Libraries –> Add JARs…
Step 4:
Copy and past the code in your layout xml file, where you want to added this admob ad.
<LinearLayout
android:id=“@+id/addViewLinearLayout”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_alignParentBottom=“true”
android:layout_marginTop=“2dp”
android:orientation=“horizontal”>
<com.google.ads.AdViewxmlns:ads=“http://schemas.android.com/apk/lib/com.google.ads”
android:id=“@+id/ad”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_gravity=“center”
ads:loadAdOnCreate=“true”
android:gravity=“center”
app:adSize=“BANNER”
app:adUnitId=“a152dcf32aa86ce “>
</com.google.ads.AdView>
</LinearLayout>
Step 5:
Open your project “AndroidManifest.xml” xml and added android permission
<uses-permissionandroid:name=“android.permission.ACCESS_NETWORK_STATE”/>
<uses-permissionandroid:name=“android.permission.INTERNET”/>
Then add Activity in your application tag
<activityandroid:name=“com.google.ads.AdActivity”
android:configChanges=“keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize”
android:screenOrientation=“portrait”/>