2.8.60 Unity SDK Integration Guide

Get started

1. Get the app key

Add your app to Appodeal and get the app key for your application, as it is used during SDK integration.

2. Link your Admob account to Appodeal

Appodeal yields optimal results in cooperation with Admob. Use our application to link them. The application will allow Appodeal to access your Admob reports over API, and will create new ad units on Admob and submit them to Appodeal. Please, see this page for more information.

If you don't have Admob account, please sign up on admob.com.


General Data Protection Regulation (GDPR) compliance

Publishers need to update their apps to collect the user consent prior to initializing our SDK (Read our guide on collecting consent here).

Publishers need to pass the boolean consent flag(with 'false' meaning that the user declined to give the consent) to the Appodeal.initialize() method of our SDK.

Appodeal.initialize(YOUR_APPODEAL_APP_KEY, adTypes, consentValue);

Integrate SDK 

Minimum OS requirements:

  • Unity 5.0.0+;
  • Android API level 14 (Android OS 4.0). You can include Appodeal SDK in apps with lower minSdkVersion.
  • iOS 8.0 or higher. You still can integrate the Appodeal SDK into a project with a lower value of minimum iOS version. On the devices that don’t support iOS 8.0+ our SDK will just be disabled.

1. Download SDK

Download Appodeal SDK 2.8.60 that includes the newest Android Appodeal SDK 2.5.8 and iOS Appodeal SDK 2.5.11 with major improvements, asynchronous ads loading support.

Use this plugin, If you are using MultiDex over custom gradle template, export to Android Studio or Eclipse with Andmore Plugin. Follow this guide to add Multidex.

 

You can also download this version from the Unity Asset Store.

If you are not using MultiDex, use Appodeal SDK below.

This version does not contain all the networks due to 65k issue resolution. If you would like to have the maximum performance, please turn on MultiDex. How to enable MultiDex in Unity.

Make sure to add Privacy Policy to your app on Google Play that links to Appodeal's Privacy Policy to avoid violating Google Play Developer Distribution Agreement.

You can use our demo app as a reference project.

Mediation A/B testing

If you want to compare Appodeal's performance to another mediation, please follow this Mediation A/B testing guide.

2. Android configuration

1. Import the Appodeal Unity plugin

Open your project in the Unity Editor. Go to Assets → Import Package → Custom package and select the downloaded *.unityPackage file. Select all the files and press Import.  

2. Google Play Services & Android Support Libraries

Appodeal requires Google Play Services 15.0.0 or higher, Android Support (also recyclerview-v7) 26.1.0 or higher and Exoplayer 2.8.4. You can add them in either way:

  • using Google Play Services Resolver;  
  • using *.unitypackage.

Option 1. Use Google Play Services Resolver

Google's Play Services Resolver now separated from Appodeal's Unity Plugin because it caused many issues in cooperation with other plugins.

Please refer to one of the following cases to resolve Appodeal's dependencies:

  • You don't have Google Play Services Resolver in your project yet:

1. Download unitypackage containing Google Play Services Resolver plugin and Appodeal's Dependencies file.

2. After the import, in the Unity editor select File → Build Settings → Android.

3. Then run Assets → Play Services Resolver → Android Resolver and press Resolve Client Jars.

4. As a result, the modules, that are required for the Appodeal SDK support, will be imported to your project. You can edit them or add other modules in the Assets → Appodeal → Editor → AppodealDependencies.xml file.

  • You are using Google Play Services Resolver in your project with another plugin:

Add following dependencies to your current dependencies.xml file:

<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.android.gms:play-services-ads:15.0.1">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>
    <androidPackage spec="com.google.android.gms:play-services-location:15.0.1">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>
    <androidPackage spec="com.android.support:support-v4:26.1.0">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-android-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>
    <androidPackage spec="com.android.support:recyclerview-v7:26.1.0">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-android-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>
    <androidPackage spec="com.google.android.exoplayer:exoplayer:2.8.4">
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>
  </androidPackages>
</dependencies>
Or you can add this file with dependencies to the Assets/Editor folder.

Option 2. Use *.unitypackage

You can import Google Play Services, Android Support libraries and Exoplayer manually using this unitypackage's:

If you use Play Services version 17 and up, add the <meta-data> tag to AndroidManifest file. 

If you're using AndroidX in your app, make sure to use NoDex SDK version with enabled Jetifier

<manifest>
	<application>
		<meta-data
			android:name="com.google.android.gms.ads.APPLICATION_ID"
			android:value="[ADMOB_APP_ID]"/>
	</application>
</manifest>

3. Configure AndroidManifest.xml

All the required AndroidManifest.xml tags are already added to the Appodeal Unity Plugin. If you don't want to use optional permissions, go to Plugins → Android → Appodeal, open AndroidManifest.xml and remove them from there.

Add required permissions to your AndroidManifest.xml file under manifest tag:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Add optional permissions to your AndroidManifest.xml file under manifest tag to improve ad targeting:
<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" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

3. iOS configuration

Set up the following keys in info.plist of your app:

In order to serve ads, the SDK requires you to allow arbitrary loads.

1. Go to your info.plist file, then press Add+ anywhere in the first column of the key list.

2. Add App Transport Security Settingskey and set its type to Dictionary in the second column.

3. Press Add+ at the end of the name App Transport Security Settingskey and choose Allow Arbitrary loads. Set its type to Boolean and its value to Yes.

You can also add the key to your info.plist directly, using this code:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
4. Since Appodeal 2.5.10 that uses GoogleMobileAds 7.49.0 you need to add a valid GADApplicationIdentifier: Add GADApplicationIdentifier into info.plist with type string as key and your app identifier as value.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>

4. Initialize SDK

Before starting to load ads, you need to initialize the Appodeal SDK, as follows:

1. Import the namespaces:

using AppodealAds.Unity.Api;
using AppodealAds.Unity.Common;
2. Add the following code within the Start() method of your main scene’s MonoBehavior: 
Appodeal.initialize("YOUR_APPODEAL_APP_KEY", adTypes, consentValue);
consentValue is boolean, with 'false' meaning that the user declines to give the consent. Read our guide on collecting consent here.

Make sure to replace "YOUR_APPODEAL_APP_KEY" with the actual app key.

Use the type codes below to set the preferred ad format:

  • Appodeal.INTERSTITIAL for interstitial.
  • Appodeal.REWARDED_VIDEO for rewarded videos.
  • Appodeal.NON_SKIPPABLE_VIDEO for non-skippable videos.
  • Appodeal.BANNER for banners.
  • Appodeal.MREC for 300*250 banners.


Please note:

1. Ad types can be combined using "|" operator. For example, Appodeal.INTERSTITIAL | Appodeal.REWARDED_VIDEO.

2. Appodeal.NON_SKIPPABLE_VIDEO - the alias of Appodeal.REWARDED_VIDEO. Both of them shouldn't be used together.

Non-skippable and rewarded videos cannot be used simultaneously. If you are not sure, which ad formats would suit you the best, check out our FAQ.


Publish your app

iOS publication

1. Update Your IDFA Settings

When you submit your application to the AppStore, you need to update its "Advertising Identifier (IDFA)" settings in order to comply with Apple advertising policy.

1. Go to the Advertising Identifier section.

2. Set Yes on the right panel.

3. Tick Serve advertisements within the app and Attribute this app installation to a previously served advertisement. 

If your app gets rejected by the App Store because of some missing usage descriptions, add those of them you need to your info.plist file:

<key>NSLocationWhenInUseUsageDescription</key>
<string><App Name> needs your location for analytics and advertising purposes.</string>
<key>NSCalendarsUsageDescription</key>
<string><App Name> needs your location for analytics and advertising purposes.</string>

Android publication

Proguard settings

If you are using Proguard, add the following to your Proguard config file:


# AdMediator
-keep class com.admediator.** { *; }

# Appodeal
-keep class com.appodeal.** { *; }
-dontwarn com.appodeal.**
-keep class com.appodealx.** { *; }
-dontwarn com.appodealx.**
-keepattributes EnclosingMethod, InnerClasses, Signature, JavascriptInterface

# Amazon
-keep class com.amazon.** { *; }
-dontwarn com.amazon.**

# Mopub
-keep public class com.mopub.**
-keepclassmembers class com.mopub.** { public *; }
-dontwarn com.mopub.**
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keepclassmembers class com.mopub.mobileads.CustomEventBannerAdapter {!private !public !protected *;}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}
-keep class * extends com.mopub.mobileads.CustomEventRewardedVideo {}
-keep class * extends com.mopub.nativeads.CustomEventRewardedAd {}
-keepclassmembers class ** { @com.mopub.common.util.ReflectionTarget *; }
-dontwarn com.mopub.volley.toolbox.**
-keepclassmembers,allowshrinking,allowobfuscation class com.android.volley.NetworkDispatcher {
void processRequest();
}
-keepclassmembers,allowshrinking,allowobfuscation class com.android.volley.CacheDispatcher {
void processRequest();
}
-keep public class android.webkit.JavascriptInterface {}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

# Applovin
-keepattributes Signature,InnerClasses,Exceptions,*Annotation*
-keep public class com.applovin.sdk.AppLovinSdk { *; }
-keep public class com.applovin.sdk.AppLovin* { public protected *; }
-keep public class com.applovin.nativeAds.AppLovin* { public protected *; }
-keep public class com.applovin.adview.* { public protected *; }
-keep public class com.applovin.mediation.* { public protected *; }
-keep public class com.applovin.mediation.ads.* { public protected *; }
-keep public class com.applovin.impl.**.AppLovin* { public protected *; }
-keep public class com.applovin.impl.**.*Impl { public protected *; }
-keepclassmembers class com.applovin.sdk.AppLovinSdkSettings { private java.util.Map localSettings; }
-keep class com.applovin.mediation.adapters.** { *; }
-keep class com.applovin.mediation.adapter.** { *; }
-dontwarn com.applovin.**

# Facebook
-keepnames public class com.facebook.ads.** { public protected *; }
-keeppackagenames com.facebook.*
-dontwarn com.facebook.ads.**

# Chartboost
-keep class com.chartboost.** { *; }
-dontwarn com.chartboost.**

# Unity Ads
-keepattributes SourceFile,LineNumberTable
-keepattributes JavascriptInterface
-keep class android.webkit.JavascriptInterface { *; }
-keep class com.unity3d.ads.** { *; }
-keep class com.unity3d.services.** { *; }
-dontwarn com.google.ar.core.**

# Yandex
-keep class com.yandex.metrica.impl.** { *; }
-dontwarn com.yandex.metrica.impl.**
-keep class com.yandex.metrica.* { *; }
-dontwarn com.yandex.metrica.*
-keep class com.yandex.mobile.ads.** { *; }
-dontwarn com.yandex.mobile.ads.**
-keepattributes *Annotation*
-keep class com.android.installreferrer.api.* { *; }
-dontwarn com.android.installreferrer.api.*

# StartApp
-keep class com.startapp.** { *;}
-keep class com.truenet.** { *;}
-dontwarn com.startapp.**
-dontwarn android.webkit.JavascriptInterface
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, LineNumberTable, *Annotation*, EnclosingMethod
-dontwarn org.jetbrains.annotations.**

# Flurry
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-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; }

# Vungle
-keep class com.vungle.warren.** { *; }
-dontwarn com.vungle.warren.error.VungleError$ErrorCode

# Vungle/Moat SDK
-keep class com.moat.** { *; }
-dontwarn com.moat.**

# Vungle/Fetch
-keepnames class com.tonyodev.fetch.Fetch

# Vungle/Okio
-keepnames class okio.Okio
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Vungle/Retrofit
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-keepnames class retrofit2.converter.gson.GsonConverterFactory
-keepnames class retrofit2.Retrofit

# Vungle/Gson
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.** { *; }

# Vungle/Google Android Advertising ID
-keep class com.google.android.gms.internal.** { *; }
-dontwarn com.google.android.gms.ads.identifier.**

# Vungle/okhttp3
-keep class okhttp3.logging.HttpLoggingInterceptor
-keepnames class okhttp3.HttpUrl

# MyTarget
-keep class com.my.target.** { *; }
-dontwarn com.my.target.**
-dontwarn com.my.target.nativeads.mediation.**
-dontwarn com.my.target.core.net.cookie.**
-dontwarn com.my.target.ads.mediation.MyTargetAdmobCustomEventBanner**
-dontwarn com.my.target.ads.mediation.MyTargetAdmobCustomEventInterstitial**
-dontwarn com.my.target.ads.mediation.MyTargetAdmobCustomEventRewarded**
-dontwarn com.my.target.ads.mediation.MyTargetMopubCustomEventBanner**
-dontwarn com.my.target.ads.mediation.MyTargetAdmobCustomEventInterstitial**
-dontwarn com.my.target.ads.mediation.MyTargetAdmobCustomEventRewarded**
-dontwarn com.my.target.ads.mediation.MyTargetMopubCustomEventBanner**
-keep class com.mopub.MopubCustomParamsUtils**{ *; }
-keep class com.mopub.mobileads.MyTargetMopubCustomEventInterstitial**{ *; }
-keep class com.mopub.mobileads.MyTargetMopubCustomEventRewardedVideo**{ *; }
-keep class com.mopub.nativeads.MyTargetCustomEventNative**{ *; }
-keep class com.mopub.nativeads.MyTargetStaticNativeAd**{ *; }
-dontwarn com.mopub.MopubCustomParamsUtils**
-dontwarn com.mopub.mobileads.MyTargetMopubCustomEventInterstitial**
-dontwarn com.mopub.mobileads.MyTargetMopubCustomEventRewardedVideo**
-dontwarn com.mopub.nativeads.MyTargetCustomEventNative**
-dontwarn com.mopub.nativeads.MyTargetStaticNativeAd**
-keep class com.google.android.exoplayer2.** { *; }
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}

# Mintegral
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.mintegral.** {*; }
-keep interface com.mintegral.** {*; }
-keep class android.support.v4.** { *; }
-dontwarn com.mintegral.**
-keep class **.R$* { public static final int mintegral*; }
-keep class com.alphab.** {*; }
-keep interface com.alphab.** {*; }

# Admob
-keep class com.google.android.gms.ads.** { *; }

# Tapjoy
-keep class com.tapjoy.** { *; }
-keep class com.moat.** { *; }
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-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; }
-keep class com.google.android.gms.ads.identifier.** { *; }
-dontwarn com.tapjoy.**

# IronSource
-keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { public *; }
-keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }
-keep public class com.google.android.gms.ads.** { public *; }
-keep class com.ironsource.adapters.** { *; }
-keepnames class com.ironsource.mediationsdk.IronSource
-dontwarn com.ironsource.mediationsdk.**
-dontwarn com.ironsource.adapters.**
-dontwarn com.moat.**
-keep class com.moat.** { public protected private *; }

# AdColonyV3
-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
-keep class com.adcolony.** { *; }
-dontwarn com.adcolony.**
-dontwarn android.app.Activity

# Inmobi
-keepattributes SourceFile,LineNumberTable
-keep class com.inmobi.** { *; }
-dontwarn com.inmobi.**
-keep public class com.google.android.gms.**
-dontwarn com.google.android.gms.**
-dontwarn com.squareup.picasso.**
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{public *;}

# Picasso
-keep class com.squareup.picasso.** {*;}
-dontwarn com.squareup.picasso.**
-dontwarn com.squareup.okhttp.**

# Moat
-keep class com.moat.** {*;}
-dontwarn com.moat.**

# AVID
-keep class com.integralads.avid.library.** {*;}

# Ogury
-dontwarn io.presage.**

# Google
-keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
-keep class com.google.android.gms.common.GoogleApiAvailability { *; }
-keep class com.google.android.gms.ads.identifier.** { *; }
-dontwarn com.google.android.gms.**

# Legacy
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.net.http.**

# 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 class * implements android.os.Parcelable
-keepclassmembers class * implements android.os.Parcelable {
public static final *** CREATOR;
}
-keep @interface android.support.annotation.Keep
-keep @android.support.annotation.Keep class *
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keep @interface com.google.android.gms.common.util.DynamiteApi
-keep public @com.google.android.gms.common.util.DynamiteApi class * {
public <fields>;
public <methods>;
}
-keep class com.google.android.gms.common.GooglePlayServicesNotAvailableException {*;}
-keep class com.google.android.gms.common.GooglePlayServicesRepairableException {*;}

# Google Play Services library 9.0.0 only
-dontwarn android.security.NetworkSecurityPolicy
-keep public @com.google.android.gms.common.util.DynamiteApi class * { *; }

# support-v4
-keep class android.support.v4.app.Fragment { *; }
-keep class android.support.v4.app.FragmentActivity { *; }
-keep class android.support.v4.app.FragmentManager { *; }
-keep class android.support.v4.app.FragmentTransaction { *; }
-keep class android.support.v4.content.ContextCompat { *; }
-keep class android.support.v4.content.LocalBroadcastManager { *; }
-keep class android.support.v4.util.LruCache { *; }
-keep class android.support.v4.view.PagerAdapter { *; }
-keep class android.support.v4.view.ViewPager { *; }
-keep class android.support.v4.content.ContextCompat { *; }

# support-v7-widget
-keep class android.support.v7.widget.** { *; }

# MultiDex
-keepnames class android.support.multidex.MultiDex

# AndroidX
-keep @interface androidx.annotation.Keep
-keep @androidx.annotation.Keep class *
-keepclasseswithmembers class * {
@androidx.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@androidx.annotation.Keep <methods>;
}
-keep class androidx.fragment.app.Fragment { *; }
-keep class androidx.fragment.app.FragmentActivity{ *; }
-keep class androidx.fragment.app.FragmentManager { *; }
-keep class androidx.fragment.app.FragmentTransaction { *; }
-keep class androidx.core.content.ContextCompat { *; }
-keep class androidx.localbroadcastmanager.content.LocalBroadcastManager { *; }
-keep class androidx.collection.LruCache { *; }
-keep class androidx.viewpager.widget.PagerAdapter { *; }
-keep class androidx.viewpager.widget.ViewPager { *; }
-keep class androidx.core.content.ContextCompat { *; }
-keep class androidx.appcompat.widget.** { *; }

# AndroidX Multidex
-keepnames class androidx.multidex.MultiDex


It's done!

You are ready to use Appodeal and implement ad types. If you have any questions, check out our FAQ or contact the support team. 

Third-party SDKs versions

NetworkAndroid SDK versioniOS SDK version
Adcolony3.3.84.1.0
Admob15.0.07.49.0
Amazon Ads5.9.02.2.17.1
Applovin9.9.16.9.3
Chartboost7.3.18.0.1
Facebook Audience Network5.5.05.5.1
Flurry11.6.09.3.1
Inmobi7.2.78.2.0
IronSource6.8.26.8.5.0
Mintegral9.13.215.7.1
myTarget5.4.75.3.5
Ogury3.0.36-
StartApp4.0.24.0.0
Tapjoy12.3.112.3.3
Unity Ads3.0.13.2.0
Vungle6.3.246.3.2
Yandex Metrica3.5.3-
Yandex Mobile Ads2.912.13.2