Step 1 : go to build.gradle file and add ,
implementation 'com.google.android.gms:play-services-ads:15.0.1'
Step 2: connect internet connection with app.For that go t0 AndroidManifest.xml file and under package add,
package="com.a7saturnapps.firstaid.firstaidsinhala">
uses-permission android:name="android.permission.INTERNET" />Step 3: Now you have to add Ad code.for that firstly you have to add Newly Scrolling activity to Android Studio.For that go to,
Under java folder right click com........... and New > Activity > Scrolling Activity
Let's say you scrolling activity name is Banner_Ad
After adding it go to,
activity_banner_ad.xml and change the code like below code.That's all.replace your adUnitiID.
xml version="1.0" encoding="utf-8"?>RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".Banner_Ad">
android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/adView">
android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="180dp" android:fitsSystemWindows="true" android:theme="@style/AppTheme.AppBarOverlay">
android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:toolbarId="@+id/toolbar">
android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/AppTheme.PopupOverlay" />
android.support.design.widget.CollapsingToolbarLayout>
android.support.design.widget.AppBarLayout>
include layout="@layout/content_banner__ad" />
android.support.design.widget.CoordinatorLayout>
com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" app:adSize="BANNER" app:adUnitId="ca-app-pub-3940256099942544/6300978111" />
RelativeLayout>
Also you can change adsize name to BANNER or SMART_BANNER
more details here :
https://developers.google.com/mobile-ads-sdk/docs/adx/android/banner