‹ AdColony Doc Home

AdColony Integration Guide

For the C++ version of cocos2d-x v3.x - (all other versions)


Certain SDKBOX plugins do not work together. If you use AdColony, then you cannot also use the Fyber and SOOMLA GROW services, in the same project.

Start from AdColony 3.0 it requires you to config your app to support all orientations, please read the details here

SDK Version


Open a terminal and use the following command to install the SDKBOX AdColony plugin. Make sure you setup the SDKBOX installer correctly.

$ sdkbox import adcolony

Important Notice

Please make sure the following settings in your project to make the plugin work well.

Disable App Transport Security

Adding the following entry to the info.plist file:


It should look like this:

Disable Bitcode support

You have to turn off Bitcode support. If you don't, cocos2d-x will fail to build.

Set your game requires full screen

If your game doesn't support all screen orientations, you will need to check Requires full screen in Xcode. If you do not, your app will fail Apple's submission process.

Whitelist canOpenURL function

This setting depends on what plugins are in your project. You may need to add the required entry to the info.plist, under LSApplicationQueriesSchemes.

JSON Configuration

SDKBOX Installer will automatically inject a sample configuration to your res/sdkbox_config.json, that you have to modify it before you can use it for your own app

Here is an example of the AdColony configuration, you need to replace <app id> and <zone id> items with your specific AdColony account information.

    "id":"<app id>",
            "zone": "<zone id>",
            "v4vc": false
            "zone": "<zone id>",
            "v4vc": true,
            "pre_popup" : true,
            "post_popup": true


Initialize AdColony

#include "PluginAdColony/PluginAdColony.h"

Showing Ads

Display an ad wherever you want from your code, by specifying ad type:




Catch AdColony events (optional)

This allows you to catch the AdColony events so that you can perform operations such as providing player rewards for watching the video.

#include "PluginAdColony/PluginAdColony.h"
class MyClass : public sdkbox::AdColonyListener
  void onAdColonyChange(const sdkbox::AdColonyAdInfo& info, bool available);
  void onAdColonyReward(const sdkbox::AdColonyAdInfo& info,
        const std::string& currencyName, int amount, bool success);
  void onAdColonyStarted(const sdkbox::AdColonyAdInfo& info);
  void onAdColonyFinished(const sdkbox::AdColonyAdInfo& info);

API Reference


static void setGDPR ( bool enabled ) ;


>>NOTE>>: please call before 'init' function
static void init ( ) ;

initialize the plugin instance.

static void show ( const std::string & name ) ;

play video ad using provided name that was specified in sdkbox_config.json

static void setListener ( AdColonyListener * listener ) ;

Set listener to listen for adcolony events

static AdColonyListener * getListener ( ) ;

Get the listener

static void removeListener ( ) ;

Remove the listener, and can't listen to events anymore

static int zoneStatusForZone ( const std::string & zoneID ) ;

Returns the zone status for the specified zone.

@deprecated please use getStatus(name) instead
static AdColonyAdStatus getStatus ( const std::string & name ) ;

Check the availability of the adcolony ads by name

static void setCustomID ( const std::string & customID ) ;

Assigns your own custom identifier to the current app user.

Once you've provided an identifier, AdColony will persist it across app
restarts (stored on disk only) until you update it. If using this method,
call it before `+ configureWithAppID:zoneIDs:delegate:logging:` so that the
identifier is used consistently across all server communications. The
identifier will also pass through to server-side V4VC callbacks.
@see getCustomID
static std::string getCustomID ( ) ;

Returns the device's current custom identifier.

@return The custom identifier string most recently set using `+ setCustomID:`.
@see setCustomID:
static std::string getUniqueDeviceID ( ) ;

Returns an AdColony-defined device identifier.

This identifier should remain constant across the lifetime of an iOS device.
The identifier is a SHA-1 hash of the lowercase colon-separated MAC address of the device's WiFi interface.
We do not recommend using this
identifier for new integrations. This method is provided for backwards compatibility.
@return The string representation of the device's AdColony identifier.
static std::string getAdvertisingIdentifier ( ) ;

Returns the device's advertising identifier.

This value can change if the user restores their device or resets ad tracking.
@return The string representation of the device's advertising identifier, introduced in iOS 6. Returns `nil` on iOS 5 or below.
@note this function only available on ios
static std::string getVendorIdentifier ( ) ;

Returns the device's vendor identifier.

@return As of version 2.3 of our iOS SDK, AdColony no longer collects the vendor identifier and this method will return `nil`. This method is provided for backwards compatibility.
@note this function only available on ios
static int getVideosPerReward ( const std::string & currencyName ) ;

Returns the number of ads that the user must play to earn the designated reward.

@note this function only available on ios
static int getVideoCreditBalance ( const std::string & currencyName ) ;

Returns the number of ads that the user has seen towards their next reward.

@note this function only available on ios
static void cancelAd ( ) ;

Cancels any full-screen ad that is currently playing and returns control to the app.

No earnings or V4VC rewards will occur if an ad is canceled programmatically by the app.
This should only be used by apps that must immediately respond to non-standard incoming events,
like a VoIP phone call. This should not be used for standard app interruptions such as
multitasking or regular phone calls.
static bool videoAdCurrentlyRunning ( ) ;

Whether a full-screen AdColony ad is currently being played.

@return A boolean indicating if AdColony is currently playing an ad.
@note this function only available on ios
static void turnAllAdsOff ( ) ;

This method permanently turns off all AdColony ads for this app on the current device.

After this method is called, no ads will be played unless the app is deleted and reinstalled.
This method could be used in the implementation of an In-App Purchase to disable ads;
make sure to allow In-App Purchases to be restored by the user in the case of deleting and reinstalling the app.
@note this function only available on ios
static void setUserMetadata ( const std::string & metadataType ,
                              const std::string & value ) ;

Provide AdColony with per-user non personally-identifiable information for ad targeting purposes.

Providing non personally-identifiable information using this API will improve targeting and unlock
improved earnings for your app. [This support article](http://support.adcolony.com/customer/portal/articles/700183-sdk-user-metadata-pass-through) contains usage guidelines.
@note this function only available on ios
static void userInterestedIn ( const std::string & topic ) ;

Provide AdColony with real-time feedback about what a user is interested in.

Providing non personally-identifiable information using this API will improve targeting and unlock
improved earnings for your app. [This support article](http://support.adcolony.com/customer/portal/articles/700183-sdk-user-metadata-pass-through) contains usage guidelines.
You can call this as often as you want with various topics that the user has engaged in
within your app or as the user engages in them. For example, if the user has started browsing
the finance section of a news app, a developer should call: `[AdColony userInterestedIn:@"finance"]`.
@note this function only available on ios
static void notifyIAPComplete ( const std::string & transactionID ,
                                const std::string & productID ,
                                int quantity ,
                                float price ,
                                const std::string & currencyCode ) ;

Call this method to report IAPs within your application. Note that this API can be leveraged to report standard IAPs as well as those triggered by AdColony’s IAP Promo (IAPP) advertisements and will improve overall ad targeting.

@see onAdColonyIAPRequest:quantity
static void requestAllAds ( ) ;

Request all ads


void onAdColonyChange ( const AdColonyAdInfo & info , bool available );

called when AdColony is finished loading.

void onAdColonyReward ( const AdColonyAdInfo & info ,
                        const std::string & currencyName ,
                        int amount ,
                        bool success );

reward was received.

void onAdColonyStarted ( const AdColonyAdInfo & info );

showing an ad has started.

void onAdColonyFinished ( const AdColonyAdInfo & info );

showing an ad has finished.

Manual Integration

If the SDKBOX Installer fails to complete successfully, it is possible to integrate SDKBOX manually. If the installer complete successfully, please do not complete anymore of this document. It is not necessary.

These steps are listed last in this document on purpose as they are seldom needed. If you find yourself using these steps, please, after completing, double back and re-read the steps above for other integration items.

Manual Integration For iOS

Drag and drop the following frameworks from the plugins/ios folder of the AdColony bundle into your Xcode project, check Copy items if needed when adding frameworks:




The above frameworks depend upon a large number of other frameworks. You also need to add the following system frameworks, if you don't already have them:


AdSupport.framework (Set to Optional)













Social.framework (Set to Optional)

StoreKit.framework (Set to Optional)


WebKit.framework (Set to Optional)

Add two separate linker flags to: Target -> Build Settings -> Linking -> Other Linker Flags:


-fobjc-arc (this allows AdColony to use ARC even if your project does not)

Manual Integration For Android

SDKBOX supports three different kinds of Android projects command-line, eclipse and Android Studio.

Copy Files

Copy the following jar files from plugin/android/libs folder of this bundle into your project's /libs folder.




Copy jni libs

Copy and overwrite all the folders from plugin/android/jni to your <project_root>/jni/ directory.

Edit AndroidManifest.xml

Include the following permissions above the application tag:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />

To enable hardware acceleration in your application tag. This tag is optional on newer SDK versions and doesn't work on version 2.3.3.

<android:hardwareAccelerated="true" />

Copy and paste the following three activity definitions just before the end of the application tags, near the bottom.

<activity android:name="com.jirbo.adcolony.AdColonyOverlay"
      android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyFullscreen"
      android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyBrowser"
      android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />

Note: if your application targets below API 13, you will likely need to remove screenSize from the configChanges property of the above activity tags.

Edit Android.mk

Edit <project_root>/jni/Android.mk to:

Add additional requirements to LOCAL_WHOLE_STATIC_LIBRARIES:


Add a call to:

$(call import-add-path,$(LOCAL_PATH))

before any import-module statements.

Add additional import-module statements at the end:

$(call import-module, ./sdkbox)
$(call import-module, ./pluginadcolony)

This means that your ordering should look similar to this:

$(call import-add-path,$(LOCAL_PATH))
$(call import-module, ./sdkbox)
$(call import-module, ./pluginadcolony)

Note: It is important to make sure these statements are above the existing $(call import-module,./prebuilt-mk) statement, if you are using the pre-built libraries.

Modify Application.mk (Cocos2d-x v3.0 to v3.2 only)

Edit <project_root>/jni/Application.mk to make sure APP_STL is defined correctly. If Application.mk contains APP_STL := c++_static, it should be changed to:

APP_STL := gnustl_static

Modify AppActivity.java

Plugin >=

  1. Find the AppActivity.java
find . -name "AppActivity.java"
  1. Replace extends Cocos2dxActivity with extends com.sdkbox.plugin.SDKBoxActivity

Example of the directory where the AppActivity.java file is located:

  - proj.android/src/org/cocos2dx/cpp/AppActivity.java
  - proj.android-studio/app/src/org/cocos2dx/cpp/AppActivity.java
  - proj.android/app/src/org/cocos2dx/cpp/AppActivity.java ( from cocos2d-x 3.17)

  - frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java
  - frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/lua/AppActivity.java
  - frameworks/runtime-src/proj.android/app/src/org/cocos2dx/lua/AppActivity.java (from cocos2d-x 3.17)

  - frameworks/runtime-src/proj.android/src/org/cocos2dx/javascript/AppActivity.java
  - frameworks/runtime-src/proj.android/app/src/org/cocos2dx/javascript/AppActivity.java ( from cocos2d-x 3.17)

Plugin <

Note: When using Cocos2d-x from source, different versions have Cocos2dxActivity.java in a different location. One way to find the location is to look in proj.android/project.properties. Example: android.library.reference.1=../../cocos2d-x/cocos/platform/android/java

In this case, Cocos2dxActivity.java should be located at:

import android.content.Intent;
import com.sdkbox.plugin.SDKBox;
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          if(!SDKBox.onActivityResult(requestCode, resultCode, data)) {
            super.onActivityResult(requestCode, resultCode, data);
    protected void onStart() {
    protected void onStop() {
    protected void onResume() {
    protected void onPause() {
    public void onBackPressed() {
          if(!SDKBox.onBackPressed()) {

Proguard (optional)

# adcolony
-dontwarn android.webkit.**

-dontwarn com.jirbo.adcolony.**
-keep public class com.jirbo.adcolony.** { public *; }

# cocos2d-x
-keep public class org.cocos2dx.** { *; }
-dontwarn org.cocos2dx.**
-keep public class com.chukong.** { *; }
-dontwarn com.chukong.**

# google play service
-keep public class com.google.android.gms.** { public *; }
-dontwarn com.google.android.gms.**

-keep class com.google.protobuf.** { *; }
-dontwarn com.google.protobuf.**

-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 public class com.sdkbox.** { *; }
-dontwarn com.sdkbox.**

Note: Proguard only works with Release builds (i.e cocos run -m release) debug builds do not invoke Proguard rules.