> For the complete documentation index, see [llms.txt](https://aatkit.gitbook.io/android-integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aatkit.gitbook.io/android-integration/ad-networks/google-mobile-ads-sdk.md).

# Google Mobile Ads SDK

#### GMA Next-Gen SDK

{% hint style="warning" %}
Starting with AATKit **3.18**, AATKit integrates the [GMA Next-Gen SDK](https://developers.google.com/admob/android/next-gen/quick-start) (`com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk`) instead of the legacy Google Mobile Ads SDK (`com.google.android.gms:play-services-ads`). The two SDKs cannot coexist in one app.
{% endhint %}

What this means for your app:

* **Minimum SDK version 24** - see [Prerequisites](/android-integration/start/setup/prerequisites.md#minimum-android-version).
* **Do not add the legacy SDK.** Remove any `com.google.android.gms:play-services-ads` (or `play-services-ads-lite`) dependency from your app. AATKit already excludes them from its own dependencies; if another library in your project still pulls them in transitively, the build fails with duplicate-class errors. Fix them with a global exclude in your app's `build.gradle`:

```gradle
configurations.all {
    exclude group: 'com.google.android.gms', module: 'play-services-ads'
    exclude group: 'com.google.android.gms', module: 'play-services-ads-lite'
}
```

* **Your own Google ad code (if any)** - if your app calls the Google Mobile Ads SDK directly, besides AATKit, migrate that code to the Next-Gen SDK following [Google's migration guide](https://developers.google.com/admob/android/next-gen/migration).
* **Native ads** - Google native ad layouts must use the Next-Gen `NativeAdView` / `MediaView` classes, see [Native Ads: Google](/android-integration/formats/native-ad/network-specifics/native-ads-google.md).
* **SDK initialization** is handled by AATKit, using the app-ID declared in the manifest (see below). You do not need to call `MobileAds.initialize` yourself.

#### Google App-ID Key

The GMA Next-Gen SDK requires the Google app-ID to be passed at initialization. AATKit initializes the SDK for you and reads the app-ID from the `com.google.android.gms.ads.APPLICATION_ID` `<meta-data>` entry of your `AndroidManifest.xml` - the same entry used by the legacy Google Mobile Ads SDK and by the Google User Messaging Platform (UMP) SDK, so nothing changes if you already declare it. In order to get the Google app-ID for your app, either [find it](https://support.google.com/admob/answer/7356431) within your own AdMob or AdManager account or contact our [support](mailto:support@gravite.net).

Declare it in your `AndroidManifest.xml`:

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

{% hint style="danger" %}
The app-ID is mandatory. AATKit reads this `<meta-data>` entry to initialize the Google Mobile Ads SDK; if it is missing, the SDK cannot be initialized and no ads from AdMob, Google AdManager or Google bidding will be served. AATKit logs the error `Cannot initialize Google Mobile Ads SDK: missing <meta-data> "com.google.android.gms.ads.APPLICATION_ID" in the application manifest.` in that case.
{% endhint %}

#### Collapsible banners

AATKit supports [Google collapsible banners](https://developers.google.com/admob/android/banner/collapsible) — banner ads that are initially shown as a larger overlay and can be collapsed by the user to the regular banner size.

To enable them, set the `collapsibleBannerOptions` property on your banner placement instance before loading ads:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
// works the same for any other banner format
val placement = AATKit.createAutoLoadBannerPlacement("YourPlacementName", BannerPlacementSize.Banner320x53))
placement.collapsibleBannerOptions = CollapsibleBannerOptions(
    position = CollapsibleBannerOptions.CollapsiblePosition.BOTTOM,
    minDelayInSeconds = 60
)
```

{% endtab %}

{% tab title="Java" %}

```java
// works the same for any other banner format
AutoLoadBannerPlacement placement = AATKit.createAutoLoadBannerPlacement("YourPlacementName", BannerPlacementSize.Banner320x53));
placement.setCollapsibleBannerOptions(new CollapsibleBannerOptions(
        CollapsibleBannerOptions.CollapsiblePosition.BOTTOM,
        60
));
```

{% endtab %}
{% endtabs %}

[CollapsibleBannerOptions](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-collapsible-banner-options/index.html) takes two parameters:

* **`position`** — where the collapsible part of the ad is anchored: `CollapsiblePosition.TOP` (banner placed at the top of the screen, ad expands downwards) or `CollapsiblePosition.BOTTOM` (banner placed at the bottom, ad expands upwards). Choose the value matching where the banner sits in your layout.
* **`minDelayInSeconds`** *(optional, default 0)* — minimum interval between collapsible ad requests. Ads requested before the delay has elapsed will load as regular, non-collapsible banners. Use this to avoid showing the expanded overlay on every banner reload. In Java, use the single-argument constructor `new CollapsibleBannerOptions(position)` if you don't need a delay.

The same property is available on all banner placement types (auto-load, multi-size, infeed, banner cache). For the `BannerCache`, set it directly on the cache instance after creation:

```kotlin
bannerCache.collapsibleBannerOptions = CollapsibleBannerOptions(
    CollapsibleBannerOptions.CollapsiblePosition.BOTTOM
)
```

{% hint style="info" %}
The default value is `null`, meaning collapsible banner support is disabled. The setting only affects ads served by Google (AdMob / Ad Manager); other networks in the waterfall are not affected.
{% endhint %}

#### AdMob Maximum Inline Banners Height

You can set the maximum height for AdMob inline adaptive banners by:

* Create an instance of [AATKitAdNetworkOptions](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-a-a-t-kit-ad-network-options/index.html) passing [AdMobOptions](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-ad-mob-options/index.html).
* Provide this instance to the [AATKitConfiguration](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-a-a-t-kit-configuration/index.html) while initialising AATKit.
* AATKit will automatically forward the specified options to the GMA during ad loading.

{% tabs %}
{% tab title="Java" %}

```java
AATKitConfiguration conf = new AATKitConfiguration(this);
AATKitAdNetworkOptions networkOptions = new AATKitAdNetworkOptions();
// [...]
AdMobOptions adMobOptions = new AdMobOptions(50);

networkOptions.setAdMobOptions(adMobOptions);
conf.setAdNetworkOptions(networkOptions);
// [...]
AATKit.init(conf);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val conf = AATKitConfiguration(this)
val networkOptions = AATKitAdNetworkOptions()
// [...]
val adMobOptions = AdMobOptions(50)

networkOptions.adMobOptions = adMobOptions
conf.adNetworkOptions = networkOptions
// [...]
AATKit.init(conf)
```

{% endtab %}
{% endtabs %}

#### DFP Maximum Inline Banners Height

You can set the maximum height for DFP inline adaptive banners by:

* Create an instance of [AATKitAdNetworkOptions](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-a-a-t-kit-ad-network-options/index.html) passing [DFPOptions](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-d-f-p-options/index.html).
* Provide this instance to the [AATKitConfiguration](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-a-a-t-kit-configuration/index.html) while initialising AATKit.
* AATKit will automatically forward the specified options to the GMA during ad loading.

{% tabs %}
{% tab title="Java" %}

```java
AATKitConfiguration conf = new AATKitConfiguration(this);
AATKitAdNetworkOptions networkOptions = new AATKitAdNetworkOptions();
// [...]
DFPOptions dfpOptions = new DFPOptions(50);

networkOptions.setDfpOptions(dfpOptions);
conf.setAdNetworkOptions(networkOptions);
// [...]
AATKit.init(conf);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val conf = AATKitConfiguration(this)
val networkOptions = AATKitAdNetworkOptions()
// [...]
val dfpOptions = DFPOptions(50)

networkOptions.dfpOptions = dfpOptions
conf.adNetworkOptions = networkOptions
// [...]
AATKit.init(conf)
```

{% endtab %}
{% endtabs %}
