Prebid SDK Integration for Android

Get started with Prebid Mobile by creating a Prebid Server account. Once your account is set up include the Prebid Mobile SDK in your app by either using Maven or by cloning the repo and using our included script to build the SDK.

SDK Integration


If you are not familiar with using Maven for build management visit the Maven website.

To include the Prebid Mobile SDK simply add this line to your gradle dependencies to get the latest stable release:

dependencies {
    // Prebid SDK
    implementation 'org.prebid:prebid-mobile-sdk:2.0.4'

Build framework from source

After cloning the repo, use Terminal or another command line tool to change to the root directory and run:


This will output the PrebidMobile framework for Android.

Add the Prebid SDK

Point to a Prebid Server

Once you have a Prebid Server, you will add the ‘account’ info to Prebid Mobile. For example, if you’re using the AppNexus Prebid Server:


If you have opted to host your own Prebid Server solution you will need to store the url to the server in your app. Make sure that your URL points to the /openrtb2/auction endpoint.


Account Settings ID

Each mobile app may have its own “account settings ID”. This is used to look up data in Prebid Server like timeout, targeting, and price granularity.

By default the Account Settings ID is set to be the same as the Account ID. i.e. the setPrebidServerAccountId() function will set both values. If you want to define a different Account Settings ID as determined in conjunction with your Prebid Server team, use the arbitrary OpenRTB method like this:

adUnitConfiguration?.ortbConfig = "{\"ext\":{\"prebid\":{\"storedrequest\": {\"id\":\"account-settings-id\"}}}}"

Initialize SDK

Once you set the account ID and the Prebid Server host, you should initialize the Prebid SDK. Use the following initialization for Prebid SDK:

PrebidMobile.initializeSdk(applicationContext) { status ->
    if (status == InitializationStatus.SUCCEEDED) {
        Log.d(TAG, "SDK initialized successfully!")
    } else if (status == InitializationStatus.SERVER_STATUS_WARNING) {
        Log.e(TAG, "Prebid Server status checking failed: $status\n${status.description}")
    else {
        Log.e(TAG, "SDK initialization error: $status\n${status.description}")

During the initialization, SDK creates internal classes and performs the health check request to the /status endpoint. If you use a custom PBS host you should provide a custom status endpoint as well:


If something goes wrong with the request, the status of the initialization callback will be SERVER_STATUS_WARNING. It doesn’t affect an SDK flow and just informs you about the health check result.

Check compatibility with your GMA SDK

If you integrate Prebid Mobile with GMA SDK, use the following method, which checks the compatibility of Prebid SDK with GMA SDK used in the app:


Check the log messages of the app. If the provided GMA SDK version is not verified for compatibility, the Prebid SDK will log a warning.

Updating your Android manifest

Before you start, you need to integrate the SDK by updating your Android manifest.

Open your AndroidManifest.xml and add the following permissions and activity declarations according to the bundle you are integrating.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


  • ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION will automatically allow the device to send user location as First Party Data, which can help increase revenue by increasing the value of impressions to buyers.
  • WRITE_EXTERNAL_STORAGE is optional and only required for MRAID 2.0 storePicture ads.

For banner and interstitial ads only, include the following custom activities (even though you won’t instantiate them directly). This is not necessary for video interstitial ads.

Custom Activities:



Interstitial ads are implemented in a dialog. For proper interstitial workflow it is recommended to use a separate Activity with configChanges attribute specified to avoid any issues which may occur on orientation change. See above example with configChanges attribute.

Add this tag to your <application> to use Google Play Services:

<meta-data android:name="" android:value="@integer/google_play_services_version" />

Set Global Parameters

There are several types of parameters app developers should consider providing to Prebid SDK:

  • Values that control Prebid SDK behavior (timeout, etc)
  • Privacy consent settings (TCF, GPP, COPPA, etc).
  • First Party Data to help bidders understand the context and/or u ser better.

See the global parameters page for details.

Supported Android versions

Prebid supports the following versions by release:

  • Prebid SDK version 1.0 or 1.1 supports Android 16+
  • Prebid SDK version 1.1.1+ supports Android 19+
  • Prebid SDK version 2.0.0+ supporst Android 16+

Setup SDK

Apply global settings with the PrebidMobile object.


String containing the Prebid Server account ID.

var pbsAccountId = PrebidMobile.getPrebidServerAccountId()


Object containing configuration for your Prebid Server host with which the Prebid SDK will communicate. Choose from the system-defined Prebid Server hosts or define your own custom Prebid Server host.


//or set a custom host


The Prebid timeout (accessible to Prebid SDK 1.2+), set in milliseconds, will return control to the ad server SDK to fetch an ad once the expiration period is achieved. Because Prebid SDK solicits bids from Prebid Server in one payload, setting Prebid timeout too low can stymie all demand resulting in a potential negative revenue impact.


var timeout = PrebidMobile.getTimeoutMillis()

Creative Factory Timeout

Indicates how long each creative has to load before it is considered a failure.


The creativeFactoryTimeoutPreRenderContent controls the timeout for video and interstitial ads. The creativeFactoryTimeout is used for HTML banner ads.


If this flag is True AND the app collects the user’s geographical location data, Prebid Mobile will send the user’s geographical location data to Prebid Server. If this flag is False OR the app does not collect the user’s geographical location data, Prebid Mobile will not populate any user geographical location information in the call to Prebid Server.


var isShareLocation = PrebidMobile.isShareGeoLocation()


The following methods enables the customization of the HTTP call to the Prebid server:

var headers = HashMap<String, String> ()
headers.put("custom-header-1", "prebid-in-action")


headers = PrebidMobile.getCustomHeaders()

Auction Response

storedAuctionResponse: Set as type string, stored auction responses signal Prebid Server to respond with a static response matching the storedAuctionResponse found in the Prebid Server Database, useful for debugging and integration testing. No bid requests will be sent to any bidders when a matching storedAuctionResponse is found. For more information on how stored auction responses work, refer to the written description on github issue 133.



Stored Bid Responses are similar to Stored Auction Responses in that they signal to Prebid Server to respond with a static pre-defined response, except Stored Bid Responses is done at the bidder level, with bid requests sent out for any bidders not specified in the bidder parameter. For more information on how stored auction responses work, refer to the written description on github issue 133.

PrebidMobile.addStoredBidResponse("appnexus", "221144");
PrebidMobile.addStoredBidResponse("rubicon", "221155");

To stop sending stored bid response signals use the following method:

void clearStoredBidResponses()


pbsDebug: adds the debug flag (“test”:1) on the outbound http call to Prebid Server. The test:1 flag will signal to Prebid Server to emit the full resolved request (resolving any Stored Request IDs) as well as the full Bid Request and Bid Response to and from each bidder.


Server Side Configuration

You can pass some SDK configuration properties from PBS to the SDK using the ext.prebid.passthrough object, supported by Prebid Server, in the stored request.

For now Prebid SDK supports the following configuration properties:

  • cftbanner - see the Prebid.creativeFactoryTimeout
  • cftprerender - see the Prebid.creativeFactoryTimeoutPreRenderContent

An example of a stored request:

  "app": {
    "publisher": {
      "ext": {
        "prebid": {
  "ext": {
    "prebid": {
      "passthrough": [
          "type": "prebidmobilesdk",
          "sdkconfiguration": {
            "cftbanner": 42,
            "cftprerender": 4242
  "test": 1

All values received in the passthrough of the bid response will be applied to the respective Prebid.* properties with the highest priority. After that, the SDK will utilize new values received in the bid response.

Integrate Ad Units

Follow the corresponding guide to integrate Prebid Mobile:

Test configs

In the table below, you can find Prebid’s test IDs that are used in the Demo Applications and that you can utilize for SDK integration validation.

Config ID Ad Format Description Custom Prebid Server Host A PBS instance that is dedicated to testing purposes.
0689a263-318d-448b-a3d4-b02e8a709d9d Stored Request ID The test account ID on the test server.
prebid-demo-banner-320-50 HTML Banner Returns a stored response that contains a Banner 320x50 winning bid.
prebid-demo-display-interstitial-320-480 HTML Interstitial Returns a stored response that contains a Interstitial 320x480 winning bid.
prebid-demo-video-outstream-original-api Outstream Video (Original API) Returns a stored response that contains a Video 320x50 winning bid.
prebid-demo-video-outstream Outstream Video (Rendering API) Returns a stored response that contains a Video 320x50 winning bid.
prebid-demo-video-interstitial-320-480-original-api Video Interstitial (Original API) Returns a stored response that contains a Video Interstitial 320x480 winning bid.
prebid-demo-video-interstitial-320-480 Video Interstitial (Rendering API) Returns a stored response that contains a Video Interstitial 320x480 winning bid.
prebid-demo-video-rewarded-320-480-original-api Rewarded Video (Original API) Returns a stored response that contains a Rewarded Video 320x480 winning bid.
prebid-demo-video-rewarded-320-480 Rewarded Video (Original API) Returns a stored response that contains a Rewarded Video 320x480 winning bid.
sample_video_response Instream Video Returns a stored response that contains a Video 320x480 winning bid. Note: on Android we have an issue with Instream Video demo example. When it is fixed the config id will be updated to the new one.
prebid-demo-banner-native-styles Native Styles Returns a stored response that contains a Native winning bid.
prebid-demo-banner-native-styles In-App Native Returns a stored response that contains a Native winning bid.