Google Mobile Ads SDK

Getting Started

The Google Mobile Ads SDK allows developers to easily incorporate mobile-friendly text and image banners as well as rich, full-screen web apps known as interstitials. An ever-growing set of "calls-to-action" are supported in response to user touch including direct access to the App Store, Google Play, Windows Phone 8 Marketplace, iTunes, maps, video and the dialer. Ads can be targeted by location and demographic data. The Google Mobile Ads SDK can be used by the following publisher types:

AdMob publishers
Access the Google AdMob network to easily monetize your application.
DoubleClick For Publishers (DFP) users
Leverage DFP to traffic, target, and serve directly-sold ads. The SDK is available to upgraded DFP users for Android and iOS platforms.
AdSense publishers
Monetize your search results pages with Google search ads.

Follow the instructions below to incorporate the Google Mobile Ads SDK into your development environment. To begin, select the tab corresponding to your particular platform.

Android (Google Play)

Requirements

  • Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (set target in project.properties to android-13).
  • The Google Mobile Ads SDK for Android requires a run-time of Android 2.3 or later (set android:minSdkVersion to at least 9 in your AndroidManifest.xml). This means you can develop with the latest version of the Android SDK and your app will still run on an earlier Android version (2.3 minimum).

Incorporating the SDK

Incorporating Google Mobile Ads into your app is a straightforward process:

  1. Add and reference the Google Play services library project in your Eclipse workspace.
  2. Add a meta-data tag in AndroidManifest.xml.
  3. Declare com.google.android.gms.ads.AdActivity in the manifest.
  4. Set up network permissions in the manifest.

1. Add and reference the Google Play services library project

See the Android instructions for how to set up the Google Play services SDK.

a. Right click on your app project in Eclipse and select Properties.

b. Select Android and then click Add.... Find the google-play-services_lib project and select OK to add the Google Play services library.

c. The project now references the Google Play services library.

2. Add a meta-data tag

Google Play services requires you to add the following meta-data tag within the element in your app's AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.company"
          android:versionCode="1" android:versionName="1.0">
  <application android:icon="@drawable/icon" android:label="@string/app_name"
               android:debuggable="true">
    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
    <activity android:label="@string/app_name" android:name="BannerExample">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
  </application>
</manifest>

3. Declare com.google.android.gms.ads.AdActivity

The Mobile Ads SDK requires that com.google.android.gms.ads.AdActivity be declared in your app's AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.company"
          android:versionCode="1" android:versionName="1.0">
  <application android:icon="@drawable/icon" android:label="@string/app_name"
               android:debuggable="true">
    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
    <activity android:label="@string/app_name" android:name="BannerExample">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <activity android:name="com.google.android.gms.ads.AdActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
  </application>
</manifest>

4. Set up network permissions

Making ad requests requires these permissions to be declared in the manifest:

INTERNET
Required. Used to access the Internet to make ad requests.
ACCESS_NETWORK_STATE
Optional. Used to check if an internet connection is available prior to making an ad request.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.company"
          android:versionCode="1" android:versionName="1.0">
  <application android:icon="@drawable/icon" android:label="@string/app_name"
               android:debuggable="true">
    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
    <activity android:label="@string/app_name" android:name="BannerExample">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <activity android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
  </application>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

You should now be able to rebuild your project without any errors.

After you have incorporated the SDK, proceed to the next guide to learn about enabling banner ads in your app.

Android (6.4.1 and earlier SDKs)

Requirements

  • Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (set target in project.properties to android-13).
  • The Google Mobile Ads SDK for Android requires a run-time of Android 1.5 or later (set android:minSdkVersion to at least 3 in your AndroidManifest.xml). This means you can develop with the latest version of the Android SDK and your app will still run on an earlier Android version (1.5 minimum).

Warning: All new Android apps created after October 14, 2011 will require an SDK that was released on or after May 11, 2011. This corresponds to version 4.1.0+ for Android. If you downloaded the library from our official download site, then you're already set. Otherwise you may have an old version of the SDK that was released prior to May 11, 2011, and your new app will not receive any ad impressions until you update your SDK.

Incorporating the SDK

Incorporating the SDK into your app is a three step process:

  1. Add the SDK JAR to your Eclipse project.
  2. Declare com.google.ads.AdActivity in AndroidManifest.xml.
  3. Set up required network permissions in the manifest.

Adding the SDK JAR

The decompressed SDK consists of a JAR, a javadoc folder and a README.

1. Right click on your app project in Eclipse and choose Properties.

2. Select Java Build Path and the Libraries tab. Then click Add External JARs... to add the Google Mobile Ads JAR.

3. Select the Order and Export tab; then, check the Google Mobile Ads JAR to include it when compiling your project.

com.google.ads.AdActivity

The SDK requires that com.google.ads.AdActivity be declared in your app's AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.company"
          android:versionCode="1" android:versionName="1.0">
  <application android:icon="@drawable/icon" android:label="@string/app_name"
               android:debuggable="true">
    <activity android:label="@string/app_name" android:name="BannerExample">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
  </application>
</manifest>

Permissions

Making ad requests requires the networking permissions INTERNET and ACCESS_NETWORK_STATE, so these must also be declared in the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.company"
          android:versionCode="1" android:versionName="1.0">
  <application android:icon="@drawable/icon" android:label="@string/app_name"
               android:debuggable="true">
    <activity android:label="@string/app_name" android:name="BannerExample">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
  </application>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

You should now be able to rebuild your project without any errors.

After you have incorporated the SDK, proceed to the next guide to learn about enabling banner ads in your app.

iOS

Requirements

  • iOS version 4.3 or later
  • Xcode 4.5 or later

Warning: All new iPad and iPhone apps created after October 14, 2011 will require an AdMob SDK that was released on or after March 15, 2011. This corresponds to version 4.0.2+ for iOS. If you downloaded the library from our official download site, then you're already set. Otherwise you may have an old version of the AdMob SDK that was released prior to March 15, 2011, and your new app will not receive any ad impressions until you update your SDK.

Incorporating the SDK

For the rest of these instructions, the project shown will be named BannerExample. When going through the exercises, simply replace BannerExample with your project's name.

The decompressed SDK consists of Objective-C headers, a runtime library and a README.

1. Right-click on your project in Xcode, choose Add Files to "BannerExample"...

2. Add everything except the add-ons folder unless you need something from there. The add-ons folder includes headers for DFP and mediation, as well as the Analytics library. Even if you are adding these in, do not add any other Xcode projects into your project.

3. The SDK library references the following iOS development frameworks which may not already be part of your project:

  • AdSupport
  • AudioToolbox
  • AVFoundation
  • CoreGraphics
  • CoreTelephony
  • MessageUI
  • StoreKit
  • SystemConfiguration
To add these frameworks, double-click the BannerExample project name. Open the Link Binary With Libraries dropdown under the Build Phases tab. Add the frameworks from the iOS SDK using the + button that becomes visible.

4. You now need to add -ObjC to the Other Linker Flags of your application target's build setting:

  1. In Xcode's project navigator, press the blue top-level project icon.
  2. Click on your target, then the Build Settings tab.
  3. Under Other Linker Flags, add -ObjC to both Debug and Release.

You should now be able to rebuild your project without any errors.

After you have incorporated the SDK, proceed to the next guide to learn about enabling banner ads in your app.

Windows Phone 8

Requirements

You can get the SDK by downloading the zip from https://developers.google.com/mobile-ads-sdk/download.

Incorporate the downloaded DLL

1. Right-click the References node in Solution Explorer and choose Add Reference.

2. Select the Browse button to find the unzipped Google Mobile Ads SDK.

3. Choose the downloaded GoogleAds.dll file and click Add.

4. Make sure that GoogleAds.dll is selected and click OK.

Selecting capabilities

With the SDK, you will need to select mandatory and optional capabilities for your app.

Windows Phone

You can modify your app's capabilities by opening WMAppManifest.XML and selecting the Capabilities tab.

Mandatory Capabilities
ID_CAP_NETWORKING Access to network services is required when requesting ads.
ID_CAP_WEBBROWSERCOMPONENT Required since the AdView is a web browser.
ID_CAP_MEDIALIB_PLAYBACK Provides access for currently playing media items.
ID_CAP_MEDIALIB_AUDIO Provides read access to audio items in media library.

After you have incorporated the SDK, proceed to the next guide to learn about enabling banner ads in your app.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.