NOTE: Future updates to this adapter will no longer be provided here. The adapter will now be maintained as part of the MoPub SDK and latest versions can be obtained from there. To raise an issue regarding the adapter, please contact support@flurry.com.
This version of the adapter works with MoPub Android SDK 4.8+ and Flurry Android SDK 6.2+. If using older versions of both the MoPub and Flurry SDK, please refer to version 5.4.0 of the adapter. Otherwise, please upgrade to the newer versions of both SDKs.
To integrate Flurry 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 Flurry SDK. Three quick steps are necessary:
- Integrate the Flurry SDK and Flurry adapter for MoPub code into your app
- Configure Flurry's Ad unit(s)
- Configure MoPub to mediate Flurry
-
If your application is not yet using Flurry analytics, create a new application on Flurry's dev portal. After logging into https://y.flurry.com, click the Admin tab and go to the Applications page. From this page, click the New App button to go through the process of adding a new app. Take note of the API key generated for your app, as that would be useful when configuring a new ad unit on MoPub.
-
Add the Flurry Android SDK to your app.
-
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 Flurry MoPub adapter classes (found in the com.mopub.mobileads & com.mopub.nativeads package) to your project. Place the following classes in com.mopub.mobileads:
Place the following classes in the com.mopub.nativeads package:
-
Follow the MoPub Custom Event integration steps for integrating banner and interstitial ads.
-
The steps to integrate Flurry 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.
If using Flurry native video ads 1, you should register the FlurryNativeAdRenderer
as a custom ad renderer and pass in your video view into
FlurryViewBinder
.
ViewBinder binder = new ViewBinder.Builder(R.layout.native_ad_list_item)
// Set up your regular ViewBinder
.build();
// Configure FlurryViewBinder with your video view
FlurryViewBinder flurryBinder = new FlurryViewBinder.Builder(binder)
.videoViewId(R.id.native_video_view)
.build();
// Register the FlurryNativeAdRenderer to handle both Flurry video and static native ads
final FlurryNativeAdRenderer flurryRenderer = new FlurryNativeAdRenderer(flurryBinder);
mAdAdapter = new MoPubAdAdapter(getActivity(), adapter);
mAdAdapter.registerAdRenderer(flurryRenderer);
//...register other native ad renderers as required
- If you plan to run ProGuard on your app before release, you will need to add the following to your ProGuard configuration file.
# Preserve Flurry
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# Google Play Services library
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
# Preserve GMS ads identifier classes
-keep class com.google.android.gms.ads.identifier.** {*;}
1 IMPORTANT: If you are not using Flurry video ads, you do not need to include the
FlurryNativeAdRenderer
and FlurryViewBinder
classes into your project. While the FlurryNativeAdRenderer
can render
both Flurry video and static native ads, you will have to explicitly include it as a renderer in your code
(see step 7 above). If you do not include the classes in your project, the MoPub SDK will use the existing
MoPubStaticNativeAdRenderer
to render Flurry static native ads.
For each MoPub ad unit that you would like to mediate Flurry through, please create a matching ad unit on the Flurry dev portal. Log into the developer portal and navigate to the App Publishing tab. On the lefthand navigation bar select Applications & Ad Units to view a list of your ad units.
To set up a new ad unit, click on the Ad Unit button on the top right.
The Basic Setup section includes fields required to define the Ad Unit Name, application, placement and/or orientation of the ad unit.
The basic setup is all you need for most integrations and you can click the "Submit" button.
Please note that mediating Flurry through MoPub requires no additional Flurry-related code. The Flurry Advertising code is already incorporated in the com.mopub.mobileads and com.mopub.nativeads package (added to your project in the previous step).
Flurry's custom events are implemented in accordance with instructions provided by MoPub.
After you incorporate the Flurry files into your project, you need to configure Flurry as a Custom Network. Please follow instructions provided by MoPub (for banner, interstitial or native) with any of the Flurry custom events class noted below:
com.mopub.mobileads.FlurryCustomEventBanner
for banner adscom.mopub.mobileads.FlurryCustomEventInterstitial
for interstitial adscom.mopub.nativeads.FlurryCustomEventNative
for Flurry native ads
NOTE: An important step to get this integration working is to configure the custom network (as described above) with the Flurry API key and Flurry Ad Unit 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:
{"apiKey":"YOUR_API_KEY","adSpaceName":"YourAdUnitName"}
You can also configure the custom event data as a line item in your MoPub order.
For full integration instructions to mediate Flurry through MoPub see here. For more info on getting started with Flurry for Android, see here and for more info on monetizing you app through Flurry see here
- Added support for Flurry native video ad rendering
- Supports MoPub SDK 4.8+
- Bug fixes
- Added Flurry ad branding logo as a MoPub extra
- Added support for MoPub 4.0.0
- Flurry Native Ad usage in Listview has the entire ad clickable.
- Allow Flurry Native Ad without any image.
- Introduced Flurry Native Ad support in the adapter