The documentation is subject to change. Please report any issues and check back for updates.
Introduction
This document provides implementation guidance for Onsite Video ads in native Android applications. It introduces a ready-to-integrate video ad wrapper that handles VAST parsing, video playback, and Open Measurement SDK compatibility for viewability and verification, helping retailers easily render, track, and measure in-app Onsite Video ad placements with minimal code.
Integration Steps
1. Add the Criteo Sample Folders to Your App Target
Add the Criteo sample folders to your app target. You can download/clone the GitHub repo here. In Android Studio, drag the following sample source folders from:player/: (CriteoVideoAdWrapper + CriteoVideoPlayer)manager/: (NetworkManager, VastManager, BeaconManager, CreativeDownloader, OMID interactors)util/: (CriteoLogger)
2. Use the Wrapper Where You Need an Ad
Pick one of the patterns in this guide and adapt the snippet:- Single Video (Fragment): Small placement with one ad on screen.
- Feed (RecyclerView): Scrolling feeds require preloading and visibility-driven playback.
Instructions for Integrating Open Measurement SDK (OMID)
Step 1: Register & Namespace
- Sign up at: https://tools.iabtechlab.com/login
- After login, confirm that a Namespace exists for your email domain.
Step 2: Build & Download (Android)
- Go to: https://tools.iabtechlab.com/omsdk
- Select your Namespace, then click Build Android.
-
When it finishes (after ~10-15 minutes), go to the Android tab, confirm the latest build by its timestamp (it should be close to the current time), and download the artifacts. Inside the package, you’ll find:
omsdk-android-{'version'}-{'namespace'}.aaromsdk-v1.js- Demo project (reference only)
Step 3: Add the OMID Android Archive (AAR) Library
- Place the
omsdk-android-<version>-<namespace>.aarfile into your module’slibs/directory. - In your module’s
build.gradle, ensure thelibs/directory is included as a flat file repository:
- Sync Gradle and verify the build succeeds.
Step 4: Add the OMID JS Library
- Place
omsdk-v1.jsin your module’sres/raw/directory (e.g.,src/main/res/raw/omsdk_v1.js). - Verify the file appears under
res/raw/in your Android Studio project view.
Step 5: Update the OMID Session Interactor
manager/omid/OMIDSessionInteractor.kt, make the changes described below.- Import package: replace
com.iab.omid.library.criteowithcom.iab.omid.library.(retailer-namespace). - Types: replace every
OMIDCriteo...type prefix withOMID(retailer-namespace)... - Update the
PARTNER_NAMEbuild config field inbuild.gradleto your organization’s partner name.
Step 6: Activate OMID
AdSession is created; otherwise, session creation will fail.Application subclass:
AndroidManifest.xml:
You are now ready to use Criteo’s Android video implementation with the OMID.
Integration Key Concepts and Code Snippets
You will find in this section short, descriptive snippets that explain behavior over boilerplate.What You Integrated
CriteoVideoAdWrapper(public API): Orchestrates VAST parsing, asset download, OMID-compliant measurement, beacon tracking, and video player lifecycle management.CriteoVideoPlayer(internal): managed by the wrapper; uses ExoPlayer (Media3) under the hood.Managers(internal):NetworkManagerVastManagerCreativeDownloaderOMIDSessionInteractorBeaconManager
Single Video (Fragment)
Code Example:src/main/java/com/iab/omid/sampleapp/BasicVideoPlayerFragment.kt
Pattern:
- Create the wrapper early; optionally enable logs.
- Resume playback in
onResume, pause inonPause. - On destroy,
release()the wrapper to free all resources.
Feed (RecyclerView)
Code Example
Fragment:src/main/java/com/iab/omid/sampleapp/FeedVideoPlayerFragment.kt
Pattern
- Set up a
RecyclerViewwith a scroll listener for visibility-based auto-play/pause. - On cell ≥50% visible:
play()(autoplays unless user previously paused). - On cell below 50% visible:
pause()(state is preserved — position/mute). - On Fragment destroy:
release()all wrappers to clean up resources.
VideoAdViewHolder manages play/pause based on visibility:
Loading from local XML (instead of URL)
- Use
CriteoVideoAdWrapper.fromXml()factory method instead offromUrl(). - Or use the
VASTSource.Xmlsealed interface variant withloadVideoAd().
Wrapper API – Quick Reference
Below are the entry points you’ll typically call from your app.Lifecycle
loadVideoAd(source: VASTSource): Start loading from a URL or raw XML source.play(): Resume or start video playback.pause(): Pause video playback and preserve state (position/mute).release(): Release all resources (call inonDestroyVieworonDestroy). The wrapper cannot be reused after this call.retry(): Retry loading after an error.
UX
toggleMute(): Enable or disable video player’s mute state.seekTo(timeMs: Long): Seek to a specific playback position in milliseconds.
Callbacks
onVideoLoaded: Fired when assets are downloaded and the ad is ready to play.onVideoStarted: Fired when playback actually begins (after play/resume is effective).onVideoPaused: Fired when playback pauses.onVideoTapped: Fired when the user taps the video view (used for click-through).onVideoError: Fired when loading or playback fails; provides the underlying Throwable.onPlaybackProgress: Periodic updates with currentMs and durationMs (milliseconds) during playback.
Configuration
CriteoVideoAdConfiguration: Property description and default values. All parameters will have default values unless otherwise specified on init.
Parameter | Description | Default value |
|---|---|---|
| Whether to automatically load VAST/assets on init. |
|
| Initial mute state for the first play. |
|
| Wrapper view background color. |
|
| Loading overlay background color. |
|
| ProgressBar indicator color while loading. |
|
| Loading message text. | “Loading video ad…” |
| Loading text color. |
|
| Error overlay background color. |
|
| Error text color. |
|
| Retry button label text. |
|
| Retry button text color. |
|
| Retry button background color. |
|
Properties
isPlaying: Boolean — Whether the video is currently playing.isMuted: Boolean — Whether the video is currently muted.currentPositionMs: Long— Current playback position in milliseconds.state: CriteoVideoAdState— Current wrapper state (NotLoaded,Loading,Ready,Error).
Sizing, UX, Performance
- Supports arbitrary video aspect ratios. Size the container
FrameLayoutto fit your layout. The wrapper selects the best media file based on aspect ratio from the VASTMediaFiles. - The wrapper automatically pauses on
onDetachedFromWindow()(RecyclerView friendly). Callrelease()explicitly when the wrapper is no longer needed. - User pause prevents auto-resume until explicitly played again. For our comprehensive video player specifications, see this page.
Technical Details (Internal): Managers & Flow
A quick tour of what happens under the hood. You should not need to call these directly.CriteoVideoAdWrapper orchestrates them for you.
NetworkManager (VAST fetch & parse)
VastAd.VastManager (VAST structure & URLs)
CreativeDownloader (asset fetch & caching)
OMIDSessionInteractor (measurement)
OMIDSessionInteractorStub) is automatically used via the OMIDSessionInteractorFactory. It logs all calls but does not emit any OMID beacons.
BeaconManager (URL tracking beacons)
CriteoVideoPlayer (UI & ExoPlayer)
CriteoLogger (structured diagnostics)
Troubleshoot
This section covers common problems you might encounter in your integration.Build & Linking
- Symptom:
[Build error] Unresolved reference: Omidor missing OMID classes - Likely cause: The OMID AAR isn’t added to your module’s libs/ directory, or the
build.gradledependency onfileTreeis missing. - Fix: Review Steps 2 & 3 from the Instruction section above. Ensure the
.aarfile is inlibs/, andbuild.gradleincludes implementationfileTree(include: ['*.aar'], dir: 'libs/'). Re-sync Gradle.
OMID Activation
Runtime error
- Symptom:
[Runtime error] OMID is not active(logged byOMIDSessionInteractor) - Likely cause: OMID is not activated before creating an OMID ad session. If
Omid.activate(context)is not called or fails, all subsequent OMID session steps will fail. - Fix:
- Review Step 4 from the Instruction section above — ensure
omsdk_v1.jsis inres/raw/. - Review Step 6 from the Instruction section above — Call
OMIDSessionInteractorFactory.activateOMSDK(this)once in yourApplication.onCreate().
- Review Step 4 from the Instruction section above — ensure
Unable to initialize OMID Partner object
- Likely cause: Partner initialization failed — Invalid partner metadata (empty name/version) or wrong package import.
- Fix: Review Step 5. Make sure to use your namespaced import (
com.iab.omid.library.<retailer-namespace>), a validPARTNER_NAMEbuild config field, and a non-emptyVERSION_NAME. For the name parameter, use the unique partner name assigned to your organization at the time of integration.
Unable to parse Verification Script URL
- Likely cause: VAST
verificationScriptUrlis invalid. - Fix: Verify the ad response/vendor config. The VAST
verificationScriptUrlmust be a valid http(s) URL.
VAST / Assets
CriteoVideoAdError.InvalidURL or CriteoVideoAdError.VastParsingFailed
- Likely cause: Bad VAST URL, network issue, or malformed XML.
- Fix:
- Check network reachability, and the VAST URL returns valid XML over HTTPS.
- Use the same XML locally via
CriteoVideoAdWrapper.fromXml()to isolate network vs. parsing errors.
CriteoVideoAdError.InvalidURL(“No valid media file URLs found in VAST”)
- Likely cause: VAST lacks an Android-playable media file (e.g., no MP4
MediaFileentries). - Fix: Ensure the VAST
MediaFilessection includes creatives with Android-compatible media (MP4 with H.264 codec recommended).
CriteoVideoAdError.AssetDownloadFailed
- Likely cause: Media or caption URL unreachable / not HTTPS / blocked by Android’s Network Security Configuration.
- Fix: Check network connectivity. Verify the URL is reachable over
https://If you need to allow cleartext HTTP for testing, configurenetwork_security_config.xmlaccordingly.
Playback
Player Failed to Load or No Playback
- Likely cause: Unsupported codec/container, non-HTTPS URL, or network security block.
- Fix: Check that the media uses an Android-supported format (MP4 with H.264/AAC recommended). Confirm the media URL is over HTTPS, and not blocked by the Network Security Configuration.
Click-through
Click‑through Does Not Open Destination
- Likely cause: Invalid/missing scheme, no app to handle the Intent, or non-HTTPS redirect chain.
- Fix: Ensure the click-through URL has a valid scheme (
https://). Verify yourAndroidManifest.xmlincludes aqueriesblock for https and http intents so the system can resolve the browser activity.