Get started with Android OpenWrap SDK for no ad server

OpenWrap SDK lets publishers leverage the power of OpenWrap to request multiple programmatic bids for their mobile in-app inventory. OpenWrap sends an initial ad call that goes out to OpenWrap partners requesting Wraps. When OpenWrap programmatically arrives at the winning bid, it returns the ad to OpenWrap SDK, which renders it in your app.

High-level process overview

  1. OpenWrap SDK sends ad request to OpenWrap.
  2. Programmatic buyers get first look at the inventory and submit a bid price.
  3. OpenWrap sends the ad call to OpenWrap partners configured by the publisher.
  4. OpenWrap returns the winning ad to OpenWrap SDK.
  5. OpenWrap SDK renders any ad returned by the ad server.

OpenWrap SDK provides the following benefits:

  • All the demand sources bid at the same time, replacing the sequential preferential ordering of buyers.
  • Advertisers have the chance to obtain the best ad inventory.
  • Publishers can potentially see up to a 50% monetization increase.

Required dependencies

Development environment 

Android Studio 3.2 or higher.

Target environment 

Android minimum API level 19; Android Version 4.4 (Kitkat) or higher.

Publisher/Placement Details

Before starting OpenWrap SDK integration with supported ads in your app, you must have the following details:

  • Publisher ID
  • OpenWrap Profile ID
  • OpenWrap Ad Unit Id

You can use PubMatic test profiles to test during SDK integration.

OR

You can create an OpenWrap Profile using your own account. To learn more about OpenWrap profile creation and management see, OpenWrap Mobile In-App Support.

Questions?

Contact your PubMatic Account Manager. 

If your app uses the Android support library

Follow the instructions provided on the AndroidX Migration page.

Integrate the OpenWrap SDK

Integrate the OpenWrap SDK in your app by updating the Gradle and AndroidManifest.xml files to satisfy this OpenWrap SDK dependency:

  1. Add PubMatic's maven repository to the allprojects section of your project-level  build.gradle file. 

    Add repository dependency
    allprojects {
       repositories {
          maven {
        	url 'https://repo.pubmatic.com/artifactory/public-repos'
    	  }	
       }
    }
  2. Now update the dependencies section of your app-level build.gradle  with OpenWrap SDK.

    Add lib dependency
    dependencies{
    	implementation 'com.pubmatic.sdk:openwrap:2.3.0'
    }
  3. Save your Gradle file and perform Gradle sync.

Add permissions to AndroidManifest.xml file

Now that you've satisfied the required dependencies, it's time to update permissions in your AndroidManifest.xml file. Android OpenWrap SDK requires only two mandatory permissions:

PermissionDescriptionMandatory
InternetRequired to access the Internet for ad-content download.Yes
Network StateRequired to access the network for ad request parameter setting.Yes
Fine LocationRequired if you want the SDK to fetch the device location.No
External StorageRequired to access SD card photo and file storage to support MRAID features.No
Read Phone StateIt is required from API level 30 onwards, to get the cellular connection type (3G/4G/etc). If this permission is not granted then Ad request parameter 'device.connectiontype' will be sent as '3' i.e. 'Cellular Network – Unknown'.No

The following code snippet adds necessary permissions to your app's AndroidManifest.xml file:

Update app AndroidManifest.xml
<manifest>
   <!--
     Mandatory permission for OpenWrap SDK
   -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <!--
     Optional permission for OpenWrap SDK
   -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>   
   <!--
     Ask this permission to user (at runtime from code) only for API 30+
   --> 
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
</manifest>

Network security configuration 

OpenWrap SDK defaults to secure ad calls and delivers only secure ads. If you configure OpenWrap SDK to serve non-secure ads, as described in, Advanced topics > Configure SSL, you should opt-out of cleartext traffic as  Android 9.0 (API 28) blocks cleartext (non-HTTPS) traffic by default , which prevents ads from rendering. To resolve this in apps running on Android 9.0 or above, include a network security config file that allowlists cleartext traffic and allows HTTP ads to render.

  1. Create the res/xml/ network_security_config.xml resource file in your app, then add the following XML:

     <?xml version="1.0" encoding="utf-8"?>
      <network-security-config>
         <base-config cleartextTrafficPermitted="true">
             <trust-anchors>
                 <certificates src="system"/>
             </trust-anchors>
         </base-config>     
     </network-security-config>
  2. Update the <application> tag of your app's AndroidManifest.xml file to match the following example:

     <manifest>
         <application
            android:networkSecurityConfig="@xml/network_security_config">
         </application>
     </manifest>

Sample apps

For more integration details, have a look at the OpenWrap SDK sample apps.

Supported ad formats

Now that you've integrated the OpenWrap Android SDK, you're ready to begin implementing ads in your app. The OpenWrap Android SDK supports following ad formats for No Ad Server configurations:

Banner ads:

Mobile banner ads usually appear as a short strip spanning the width of the app page or screen, positioned above or below the app content. Banner ads can be static or animated images, any mobile-compatible rich media ad format, or in-banner video.

Interstitial ads:

Mobile interstitial ads fill the screen or page and require the user to dismiss the ad before they can view/access the app's main content. Interstitial ads also support  static or animated full-screen images, any mobile-compatible rich media ad format, or full-screen video.

Rewarded ads:

Mobile rewarded ads fill the screen or page and require the user to dismiss the ad before they can view/access the app's main content. Rewarded ads support only full-screen video ad formats. Once video playback completes the user receives in-app rewards.

Table of Contents

« About Android OpenWrap SDK

Do you have feedback on this document? Let us know: email us.