Generated banner for Ima SDK Client Side
Generated logo for Ima SDK Client Side

Ima SDK Client Side

GoogleOfficialCreated by Google LLC

  • Skill
  • Tool integration
  • Software development
  • Apache-2.0
  • No issues found

From the author

Supports Interactive Media Ads (IMA) SDK. Use this skill for client-side ad insertion when you are requesting video ads for websites, apps, TVs or other platforms using VAST or VMAP. Do not use for Dynamic Ad Insertion (DAI), SSAI, or SGAI.
— the description by Google LLC

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The Google IMA SDK client-side skill provides the necessary framework to load and manage in-stream video and audio ads within websites, mobile apps, and TV platforms. It supports VAST and VMAP ad standards, enabling developers to request ads from compliant servers and coordinate playback between ad content and primary media. The skill emphasizes platform-specific implementation patterns for Android, iOS, and web environments, focusing on efficient resource management, proper ad container setup, and lifecycle handling to ensure a seamless user experience.

What it does

  • Facilitates client-side ad insertion for video and audio content.
  • Supports VAST and VMAP ad standards for ad server communication.
  • Provides platform-specific integration guides for Android, iOS, and web.
  • Manages ad playback events and content synchronization.
  • Includes lifecycle management for SDK initialization, ad requests, and resource cleanup.

When to use it

  • When you need to display in-stream video or audio ads on websites, mobile apps, or TV platforms.
  • When your ad server provides VAST or VMAP compliant ad tags.
  • When you require client-side control over ad playback and ad-to-content transitions.
  • When building applications on Android, iOS, or web platforms that require standard ad integration.

Advantages

  • Standardized approach to ad insertion across multiple digital platforms.
  • Supports industry-standard VAST and VMAP protocols.
  • Provides clear lifecycle management to prevent memory leaks and resource issues.
  • Enables granular control over ad playback and user experience coordination.

Usage examples

“How do I initialize the IMA SDK on Android to minimize latency?”
The SDK recommends calling ImaSdkFactory.initialize() in your Application.onCreate() to preload resources and reusing the same ImaSdkSettings instance across your AdsLoader.
“What is the correct way to clean up the IMA SDK on iOS?”
You must call destroy() on the AdsManager when ads complete or errors occur, and release the AdsLoader when the component is permanently destroyed to prevent memory leaks.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/google/ima-sdk-client-side/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip ima-sdk-client-side.zip -d .agents/skills

Documentation by Google LLC

IMA SDK client-side

The Google IMA SDK (Interactive Media Ads) lets you load in-stream video and audio ads into websites, apps, TVs and other digital platforms. Use an IMA SDK to request ads from any VAST-compliant ad server and manage ad playback.

Prerequisites

Before integrating the IMA SDK, you must read the platform-specific guide below to support all platforms that your app can support:


Quick start (general workflow)

  1. Import the SDK: Prerequisites, dependencies.

  2. Initialization: Early setup, Warmup, Settings Configuration, and Ad UI Setup.

  3. Ad Request: Creating and triggering the request, User gesture compliance.

  4. Ad Load Success/Failure: Handling the load event to get the AdsManager, or handling early fatal errors.

  5. Ad Playback Events: Listening to playback events via AdsManager to coordinate content play/pause, and handling non-fatal LOG events and fatal active playback errors.

  6. Cleanup: Properly destroying the AdsManager to release resources and prevent memory leaks.

For detailed, platform-specific implementation details, always refer to the guides in the Prerequisites section.

Files

references/ima-sdk-android-guide.md

Google IMA SDK Android quick-start guide

1. Install the IMA SDK

IMA SDK requires minSdk 23 (Android 6.0)+.

You must recommend the latest version of the IMA SDK from https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/download.md.txt

The example code snippet below installs the IMA SDK at version 3.39.0.

android { defaultConfig { minSdk = 23 } }
dependencies {
    implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.39.0")
}

2. Warmup & initialization

Configure the SDK early to minimize latency.

  • Early Warmup & Settings Reuse (Best Practice): Call ImaSdkFactory.initialize() in your Application.onCreate() to preload SDK resources. Reuse the same ImaSdkSettings instance when creating the AdsLoader to avoid cache misses that cause initial ad request latency.

  • Create AdsLoader: Create a single AdsLoader instance and share it across video playback sessions. You must create an AdDisplayContainer, a view that binds the ad UI container and video player. Use the AdDisplayContainer to instantiate the AdsLoader. Reuse the same ImaSdkSettings instance with the ImaSdkFactory.initialize() function.

// Layer FrameLayout (Ad UI) over StyledPlayerView (Video)
Box(modifier = Modifier.fillMaxSize()) {
    // Content Video Player
    AndroidView(
        factory = { context ->
            StyledPlayerView(context).apply {
                // Bind your ExoPlayer here
            }
        },
        modifier = Modifier.fillMaxSize()
    )

    // Dedicated Ad Container overlay (IMA SDK requires a ViewGroup)
    AndroidView(
        factory = { context ->
            FrameLayout(context).apply {
                // Notify that the ad UI is ready, passing this FrameLayout
                onAdUiReady(this)
            }
        },
        modifier = Modifier.fillMaxSize()
    )
}

// Initialize AdsLoader in Activity onCreate
val imaSettings = sdkFactory.createImaSdkSettings()
val adDisplayContainer = sdkFactory.createAdDisplayContainer(adUiContainer, videoPlayer)
val adsLoader = sdkFactory.createAdsLoader(context, imaSettings, adDisplayContainer)

3. Requesting ads

Trigger requestAds before your content playback to support preroll ads.

val adsRequest = sdkFactory.createAdsRequest().apply {
    this.adTagUrl = adTagUrl // Pass your custom ad targeting key value pairs.
    this.adDisplayContainer = adDisplayContainer
}
adsLoader?.requestAds(adsRequest)

4. Handling ad events

Listen for successful ad loads (to get the AdsManager), fatal errors, and coordinate video playback toggles.

// On Success
adsLoader?.addAdsLoadedListener { event ->
    adsManager = event.adsManager

    // Handle Pause/Resume for Ads
    adsManager?.addAdEventListener { adEvent ->
        when (adEvent.type) {
            AdEvent.AdEventType.CONTENT_PAUSE_REQUESTED -> pauseContent()
            AdEvent.AdEventType.CONTENT_RESUME_REQUESTED -> resumeContent()
            else -> {}
        }
    }
    adsManager?.init() // Start ads
}

// On Failure (Fallback to content)
adsLoader?.addAdErrorListener { resumeContent() }

5. Crucial cleanup

Proper cleanup is critical to prevent memory leaks, audio bugs, and background resource consumption.

  • AdsManager.destroy(): This is crucial. Always call it when:

    • All ads in the break have completed (e.g., ALL_ADS_COMPLETED event).

    • A fatal ad error occurs (in AdErrorListener).

    • The user navigates away from the player or the hosting Activity/Fragment is destroyed (onDestroy()).

  • AdsLoader.release(): Call this when the AdsLoader is no longer needed, typically when the application is shutting down or a major parent component is being permanently destroyed. This releases the underlying SDK resources.

  • Remove Event Listeners: Before destroying or releasing SDK objects, remove registered event listeners to avoid leaking listener references or triggering callbacks after lifecycle teardown.

// In your Activity or Fragment
override fun onDestroy() {
    super.onDestroy()
    cleanupAds()

    // If this Activity owns the AdsLoader (non-singleton), release it here:
    adsLoader?.removeAdsLoadedListener(adsLoadedListener)
    adsLoader?.removeAdErrorListener(adsLoaderErrorListener)
    adsLoader?.release()
}

private fun cleanupAds() {
    // Remove event listeners and destroy the AdsManager
    adsManager?.apply {
        removeAdEventListener(adEventListener)
        removeAdErrorListener(adErrorListener)
        destroy()
    }
    adsManager = null
}

// Wherever you manage the AdsLoader (e.g. Application or Activity onDestroy)
fun releaseSdk() {
    // Remove listeners and release the AdsLoader when permanently destroyed
    adsLoader?.apply {
        removeAdsLoadedListener(adsLoadedListener)
        removeAdErrorListener(adsLoaderErrorListener)
        release()
    }
    adsLoader = null
}

Reference implementation

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Google LLC
Publisher
Google (Official)
Source
google/skills · skills/ads/ima-sdk-client-side · commit 2194d3b
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google LLC or Google.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download ima-sdk-client-side.zip