This version of the adapter works with MoPub Android SDK 4.12+ and Ad2iction Android SDK 3.3.0. Otherwise, please upgrade to the newer versions of both SDKs.
To integrate Ad2iction as the Custom Native Network in the MoPub ad serving flow, you need the Custom Event Class code incorporated into your application in addition to the Ad2iction SDK. Three quick steps are necessary:
- Integrate the Ad2iction SDK and Ad2iction adapter for MoPub code into your app
- Configure Ad2iction's Ad unit(s)
- Configure MoPub to mediate Ad2iction
-
If your application is not yet using Ad2iction, please contact Ad2iction.
-
Add the Ad2iction Android SDK.
-
Add the Google Play Services SDK to your project. This is required for Android Advertising ID support. See http://developer.android.com/google/playservices/setup.html.
-
Add the Ad2iction MoPub adapter classes (found in the com.mopub.nativeads package) to your project. Place the following classes in the com.mopub.nativeads package:
-
The steps to integrate Ad2iction Native Ads via MoPub are similar to those described here:
- Create an XML layout for your native ads
- Define where ads should be placed within your feed
- Create a MoPubAdAdapter to wrap your existing
Adapter
subclass and begin loading ads.
And you should register the Ad2ictionNativeAdRenderer
as a custom ad renderer.
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_ad_list_item)
// Set up your regular ViewBinder
.build();
// Register the Ad2ictionNativeAdRenderer to handle static native ads
final Ad2ictionNativeAdRenderer ad2ictionRenderer = new Ad2ictionNativeAdRenderer(viewBinder);
mAdAdapter = new MoPubAdAdapter(getActivity(), adapter);
mAdAdapter.registerAdRenderer(ad2ictionRenderer);
//...register other native ad renderers as required
- Add permissions in AndroidManifest:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- Add Activity declaration in AndroidManifest:
<activity
android:name="com.ad2iction.mobileads.Ad2ictionActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity
android:name="com.ad2iction.mobileads.MraidActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Translucent"/>
<activity
android:name="com.ad2iction.common.Ad2ictionBrowser"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity
android:name="com.ad2iction.mobileads.MraidVideoPlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
- If you plan to run ProGuard on your app before release, you will need to add the following to your ProGuard configuration file.
# Ad2iction Proguard Config
# NOTE: You should also include the Android Proguard config found with the build tools:
# $ANDROID_HOME/tools/proguard/proguard-android.txt
# Add this line if you use Admob Adapter
-libraryjars \libs\ad2iction-mediation-adapteradmob.jar
-libraryjars \libs\ad2iction-sdk.jar
# Keep public classes and methods.
-keepclassmembers class com.ad2iction.** { public *;}
-keep public class com.ad2iction.**
-keep public class android.webkit.JavascriptInterface {}
-keep class * extends com.ad2iction.mobileads.CustomEventBanner {}
-keep class * extends com.ad2iction.mobileads.CustomEventInterstitial {}
-keep class * extends com.ad2iction.nativeads.CustomEventNative {}
-keep class com.google.android.gms.common.GooglePlayServicesUtil {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {*;}
For each MoPub ad unit that you would like to mediate Ad2iction through, please contact Ad2iction.
Ad2iction's custom events are implemented in accordance with instructions provided by MoPub.
After you incorporate the Ad2iction files into your project, you need to configure Ad2iction as a Custom Network. Please follow instructions provided by MoPub (for native) with any of the Ad2iction custom events class noted below:
com.mopub.nativeads.Ad2ictionCustomEventNative
for Ad2iction native ads
NOTE: An important step to get this integration working is to configure the custom network (as described above) with the Ad2iction API key and send them as server extras (in the "Custom Event Class Data" field on the MoPub UI).
The custom event class data should be in the following JSON format:
{"response_body_key":"YOUR_API_KEY"}
You can also configure the custom event data as a line item in your MoPub order.
- Introduced Ad2iction Native Ad support in the adapter
- Supports MoPub SDK 4.12+