Skip to main content

Overview

Native ads are an ad format that allows you to freely customize the ad UI to match your app’s design. You can provide a natural user experience by individually placing elements such as ad creatives (images, videos), headline, body, and CTA buttons.

Key Features

  • Complete UI Customization: Freely configure ad layout to match your app’s design system
  • Various Media Support: Image and video ad creative support
  • Flexible Click Area Settings: Full click or individual element click handling
  • Profile Information Display: Advertiser profile logo, name, and link support

Classes and Interfaces

AdropNativeAd

Main class for loading and managing native ads.
String
required
Ad unit ID (issued from console)
String
ID for contextual targeting (optional)
AdropNativeAdListener
Listener to handle ad events
Boolean
default:"false"
Whether to use custom click handling

Key Properties

AdropNativeAdView

Container view for displaying native ads.
Boolean
default:"false"
Whether to enable entire area click. When set to true, click events occur on the entire ad view area.

Key Methods

AdropMediaView

Media container view for displaying ad images or videos.
For video creatives, AdropMediaView must be bound through AdropNativeAdView.setMediaView(...). Reading ad.asset and playing the URL with your own player (ExoPlayer, MediaPlayer, or any third-party library) bypasses the SDK’s video tracking pipeline, so VTR is not measured and onAdVideoStart / onAdVideoEnd never fire. See Video Tracking and VTR.

AdropNativeAdListener

Interface for handling ad events.

AdropNativeAdProfile

Data class containing advertiser profile information.

Implementation Guide

1. XML Layout Setup

Define the layout to display native ads. Use AdropNativeAdView as the root and place ad elements inside.
res/layout/native_ad_layout.xml

2. Load and Display Ad (Kotlin)

3. Load and Display Ad (Java)

Java

Advanced Features

Entire Click Area Setting

You can set the entire ad view area to trigger click events.
When isEntireClick is set to true, the entire ad view becomes a clickable area. Individual element click listeners will not work.

Individual Element Click Listeners

You can set custom click listeners on specific ad elements.

Contextual Targeting

You can request ads matching a specific context.

Using in RecyclerView

You can display native ads as items in a RecyclerView.
RecyclerView Adapter

Test Unit IDs

Use the following test unit IDs during development and testing.
Be sure to replace with actual unit IDs before production deployment.

Lifecycle Management

Resource Release in Activity/Fragment

Native ads must be released when no longer in use to prevent memory leaks.

Resource Release in RecyclerView

When using ads in a RecyclerView Adapter, all ads must be released when the Activity or Fragment is destroyed.

Video Tracking and VTR

Adrop measures video metrics for native creatives — including impression-to-completion (VTR), onAdVideoStart, and onAdVideoEnd — only when the video is rendered through the SDK’s media surface (AdropMediaView bound via AdropNativeAdView.setMediaView(...)). This applies to the ad’s main media (Media 1). For the other media items of a multi-media creative, see Multi-Media Creatives. The AdropNativeAd.asset property returns a URL pointing to the underlying image or video file. It is exposed as supplementary metadata (for example, for thumbnails or your own analytics); it is not intended to drive playback.
Do not feed the asset URL into a custom video player (ExoPlayer, MediaPlayer, or any third-party player) for a video native ad. When the SDK’s media surface is bypassed:
  • VTR (Video Through Rate) is not collected for that placement.
  • onAdVideoStart / onAdVideoEnd callbacks never fire.
  • Aggregate video performance for the unit will under-report or report zero.
Click (onAdClicked) and impression (onAdImpression) tracking still work because they are wired to the container view, but the video-specific signals are lost.
Bind the SDK media surface for every video native:
If a placement absolutely requires a custom player and you accept that VTR will not be measured, you can still surface click and impression attribution by keeping the ad bound to AdropNativeAdView. In that case, treat the placement as non-VTR inventory in your internal reporting and avoid mixing it with SDK-measured video performance.

Multi-Media Creatives

Requires adrop-ads 1.16.0 or later. If you use backfill, update adrop-ads-backfill to the same version.
If a native unit has two or more media items, its creatives contain a file for each media item. extraAssets holds every media item of the ad, keyed by the media ID set in the console. Media 1 is always m1, and the other media items use the IDs shown in Media Size on the Ad Unit detail screen, such as m2 and m3.
  • Media 1 (m1) is the same media as asset and creative. Keep displaying it with AdropMediaView, and draw only the other media items yourself.
  • extraAssets is empty for creatives of units with a single media item and for backfill ads. Display those ads as usual.
  • Look up media items by ID instead of relying on their order.
  • If the ad is served in dark mode, image media items are dark mode images too.
  • To check your layout with a multi-media creative, preview the creative on a test device.

AdropNativeAsset

Displaying Media Items

  • Image: Set isEntireClick = true. Media items you draw aren’t views registered with the SDK, so in the default click mode a tap on them isn’t counted as a click. With entire click, if Media 1 is a video, taps on its player controls also count as ad clicks. Don’t load the creative HTML of an image: it doesn’t report clicks to Adrop.
  • Video: Play the creative HTML, not the asset URL. The HTML contains the video player and its tracking, so video metrics are measured only through it. Place the WebView outside AdropNativeAdView: inside, entire click turns every tap, including taps on the player’s controls, into an ad click. Load the HTML when the ad is about to appear on screen, not in advance.
  • Landing page: When a user taps the video, its HTML reports the click and asks to open the landing page in a new window or in the same window. With the default WebView settings, both requests arrive in shouldOverrideUrlLoading, so open the requested URL there.

Impressions and Clicks

Impressions, clicks, and video metrics are counted once per ad, not per media item, even when both the SDK and a media item report them.
Which taps on a video count as clicks depends on the unit’s video controller setting. With the controller off, every tap on the video is a click. With it on, taps on the play and mute controls aren’t clicks.

Example

This example shows Media 2 (m2) as an image inside AdropNativeAdView, or as a video right below it. Replace m2 with the ID of your unit’s media item.
res/layout/native_multi_media_ad.xml
In a RecyclerView, create the media item’s WebView when you bind the ad, and remove and destroy it in onViewRecycled().

Best Practices

1. Display Only Required Elements

You don’t need to display all ad elements. Selectively use only the elements needed to match your app’s design.

2. Use Image Loading Libraries

Use image loading libraries like Glide or Coil when displaying icon, cover, and profile images.

3. Reuse Ad Views

When displaying ads in a RecyclerView, cache and reuse ad instances.

4. Appropriate Ad Placement

Place ads naturally without degrading user experience.
  • Content feed: 1 ad every 5-10 items
  • Detail screen: Place at bottom of content
  • Scroll view: Place to match natural content flow

5. Error Handling

Implement appropriate fallback handling for ad load failures.

Complete Example


Batch Loading (loads)

Use AdropNativeAd.loads() to request multiple native ads in a single batched call. This is useful for prefetching a pool of ads to insert into feeds, carousels, or paginated lists.

Signature

Usage

Listener Callbacks

The singular onAdReceived / onAdFailedToReceive callbacks are not invoked on the loads() path. Use onAdsReceived / onAdsFailedToReceive as the sole batch signals.

Constraints

  • Maximum 5 ads per call. If the server returns more, only the first 5 are delivered.
  • Backfill is not applied. If no direct ads fill, onAdsFailedToReceive is called with ERROR_CODE_AD_NO_FILL regardless of backfill configuration.
  • Do not call destroy() inside onAdsReceived. Bind each ad to an AdropNativeAdView via setNativeAd(...) or store for later lifecycle, then destroy() on the parent Activity.onDestroy() (or equivalent).
  • Unlike AdropBanner.loads(), the native batch waits for every returned ad to finish rendering before firing onAdsReceived, so each instance is fully rendered on delivery.

Backfill Ads

When backfill ads are enabled, backfill ads are automatically loaded when direct ads are unavailable. Use the isBackfilled property to check if the ad is a backfill ad.

AdChoices Position

For backfill native ads, you can choose which corner displays the AdChoices badge. Set preferredAdChoicesPosition on the AdropNativeAd instance before calling load().
This setting is a preferred hint for the backfill network and applies only to backfill native ads — direct ads are not affected. The value must be set before load() is called. The backfill network may override the position depending on its policy.
To use backfill ads, add the io.adrop:adrop-ads-backfill dependency. See Getting Started.

Preloading Backfill Ads (preload)

Starting with SDK 1.17.0, you can use AdropNativeAd.preload() to preload a backfill native ad. When a native ad that you load() with the same unit ID and the same AdChoices position gets no direct ad and falls back to a backfill ad, it uses the preloaded ad right away instead of requesting a backfill ad again. load() still requests a direct ad first, regardless of preload. If a direct ad is received, the preloaded ad is kept as is. If you don’t call preload, the behavior is the same as before.

Requirements

  • Both io.adrop:adrop-ads and io.adrop:adrop-ads-backfill must be 1.17.0 or later.
  • Preload fetches a backfill ad only when the server has told the app that there are no direct ads to show right now. Otherwise, it ends with ERROR_CODE_AD_PRELOAD_SKIPPED without requesting a backfill ad. This is a normal result in apps that have direct ad campaigns.
  • Right after the app is installed, right after you change the App Key, and right after you switch to a different user with setUID, preload ends with ERROR_CODE_AD_PRELOAD_SKIPPED until the server response arrives.
  • With test unit IDs, preload always ends with ERROR_CODE_AD_PRELOAD_SKIPPED.

Usage

Pass the Activity that will display the ad as context, and call preload right before you open the screen that contains the native ad. A preloaded ad is discarded after 30 minutes if it isn’t used, so call preload only for ads you’re about to display. You don’t need to wait for the result before calling load(). If the ad is still being fetched, load() waits for that result and uses it.
To use the preloaded ad, set the preferredAdChoicesPosition of the AdropNativeAd you load() to the same value you passed to preload. Both default to TOP_RIGHT.

When a Preloaded Ad Is Used

  • Same unit ID and same AdChoices position: The AdChoices position is fixed when the backfill ad is fetched, so the preferredAdChoicesPosition of the ad you load() must match the value you passed to preload. If it differs, the preloaded ad is kept as is, and load() requests a backfill ad as usual.
  • Same Activity: A preloaded ad isn’t used by an AdropNativeAd created with a different Activity from the one you passed to preload (for example, if you preload in a splash Activity and call load() in the main Activity). When the Activity you passed to preload finishes, the preloaded ad is discarded as well.
  • Used only once: A preloaded ad is gone once a single load() uses it. To preload again, call preload again.
  • Lifetime and count: An ad that isn’t used within 30 minutes is discarded. Only 1 ad is kept per unit and AdChoices position, and native ads keep up to 5 different combinations. When there are more than 5, ads are discarded starting with the one received first.
  • Calling again: Calling preload again with the same unit and AdChoices position doesn’t make a new request. If an ad has already been preloaded, onAdPreloadReceived is called without a new request; if one is still being fetched, you get that load’s result (success or failure). You can’t use preload to refresh an ad. However, if the user consent status has changed in the meantime, or if you call it with a different Activity, the existing ad is discarded and a new one is fetched.
  • Consent status changes: If the user consent status changes after an ad is preloaded, that ad isn’t used by load().

Result Callbacks

The following callbacks have been added to AdropNativeAdListener. Both are optional to implement, and each time you call preload, one of the two is called once on the main thread. No other listener callbacks are called for preload. contextId returns the value you passed to preload as is. It isn’t used to select a preloaded ad.

Failure Codes

Don’t call preload again right away inside the failure callback. If the result doesn’t change — for example, when the backfill dependency is missing — the calls repeat endlessly. Call it again later, such as before you open the next screen.

Next Steps

Banner Ads

Implement banner ads

Interstitial Ads

Implement interstitial ads

Targeting Settings

User properties and context targeting

Reference

Classes, listeners, error codes