You are here: Developers > OpenX Bidder for Apps Android > Integrating the adapter into your app

Integrating the adapter with your app

Last updated on May 31, 2017

  1. Place OpenXPrebidder.aar into your project’s /libs folder.

    Place .aar file in libs folder

  2. Add the following in the allprojects section of your build.gradle file under your project root.
    
    flatDir {
    	dirs 'libs'
    }
    		

    Add to allprojects in build.gradle file

  3. Add compile (name:'OpenXPreBidder', ext:'aar') to the dependencies section of your build.gradle in your desired app module that uses OpenX BidderOpenX's header bidding solution. Bidder enables publishers to realize the true value of their direct and indirect inventory in real time. "Bidder" can also mean a program designed to bid in real time on inventory in the OpenX Ad Exchange..

    Add to dependencies

  4. Select Tools > Android > Sync Project with Gradle Files:

    Sync with gradle files

    The OpenX Bidder library is now successfully added to your project. All Bidder classes should be resolved by now. You can verify by calling any OpenX Bidder API, such as BFAConfiguration.getBidderVersion().

  5. Please make sure you have the following in your AndroidManifest.xml:
    
    ....
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- to get the location details for ad requests -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- to get the network details for ad requests -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- to get the carrier data for ad requests -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <!-- extract a hardware MAC addresses for ad requests -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!-- For MRAID 2 -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    ...
     
    <activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
    <activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
    <activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    			
  6. In order to render the ads returned from OpenX, you will need to implement Mopub's CustomEventBanner and CustomEventInterstitial classes.

    We have provided reference implementations of both within the provided project as OXMBannerCustomEvent and OXMInterstitialCustomEvent. Place the directories OpenXAndroidSDKDemo->"com.mopub.mobileads" and OpenXAndroidSDKDemo->"com.mopub.mraid" into your app, maintaining the same structure.

Next steps

There are two ways to proceed with integrating OpenX Bidder for Apps into your app:

  • QueuedBidderManager (recommended) - This class handles prefetch and queueing of a number of ads on your behalf.
  • BidderManager - This class offers more control for how and when to fetch ads. You are responsible for adding any prefetching/caching logic on your own.

Feedback form