Google Admob implementation on android project

Google Admob implementation on android project

All are described here here https://developers.google.com/admob/android/quick-start.
I am only arrange step by step procedure-

Step 1 :
Example project-level build.gradle (excerpt)
add this on build.gradle(global) in repositories brackets

maven {
            url "https://maven.google.com"
        }

as like –

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

Step 2 :

Example app-level build.gradle (excerpt)
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services-ads:15.0.0'
}

Step 3 :

Update your AndroidManifest.xml
Add your AdMob App ID to your app’s AndroidManifest.xml file by adding the tag shown below. You can find your App ID in the AdMob UI.

<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="REPLACE_WITH_YOUR_ADMOB_APP_ID"/>
    </application>
</manifest>

Step 4 :

Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() with your AdMob App ID. This needs to be done only once, ideally at app launch.

Here’s an example of how to call the initialize() method in an Activity:

Example MainActivity (excerpt)

import com.google.android.gms.ads.MobileAds;

public class MainActivity extends AppCompatActivity {
    ...
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
        MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
    }
    ...
}

So basic works is done . Now our app is ready to implement Banner , Interstitial and Rewards Video ads.

1 : How to implement Banner Ads
2 : How to implement Interstitial Ads
3 : How to implement Rewards Video Ads

Leave a Reply

Your email address will not be published. Required fields are marked *