Show Sidebar

Cocos2d-x SDK for Android

Rất tiếc, mục này chỉ tồn tại ở English. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

For Cocos2d-x version 3 and above.


VMAX Cocos2d-x Ad SDK is a wrapper around the VMAX Native android Ad SDK. Cocos Studio supports three languages. The current release of SDK only supports integration with C++ version of Cocos2d-x.

Mediation Partners


  • AdColony
  • AdMob
  • Chartboost
  • Facebook Audience Network
  • Flurry
  • Millennial Media
  • Vungle

Interstitial Video

  • Adcolony
  • Chartboost
  • Vungle

Rewarded Video

  • AdColony
  • Chartboost
  • Pokkt
  • UnityAds
  • Vungle

Native Icon

  • Facebook Audience Network (Native)
  • InMobi (Native)

Integrating the VMAX SDK

Prerequisites for Integration

  1. Cocos2d-x 3.x
  2. Android Studio
  3. Android NDK
  4. Apache Ant

Basic Setup

  1. Copy VMAXCocos2dHelper.cpp & VMAXCocos2dHelper.h and paste it to your Classes folder.
  2. In the Cocos2d-x Scene you wish to integrate the VMAX SDK, import the VMAX Cosos2d-x header as:
  3. Add VMAXCocos2dHelper.cpp class path inside jni/ file.
    For Example – LOCAL_SRC_FILES := ../../Classes/VMAXCocos2dHelper.cpp \
  4. Compile your application to generate the .so file.
  5. Import the generated by Cocos2d-x in Android Studio.
  6. Add module vmax.aar from Plugin/AndroidVMAXSDKAar directory
  7. Add necessary mediation partners to your package.
    Mediation Files/ directory contains libraries (jar/aar/library projects) and adapters(java files with package) of the supported mediation partners.
  8. Alternatively, if you’re using Eclipse, follow the steps mentioned here.
  9. Create a package in your src directory of project and copy file into that.
  10. Must call
    in your Activity onCreate() method.
  11. Maintain Activity specific lifecycle in your activity class using Cocos2dVMAXAdSDK mVMAXAdSDK object


Instantiating Interstitial Ads

Use the following snippet to create the Interstitial ad and add listener to it:

Instantiating Rewarded Video Ads

Use the following snippet to create the Rewarded video ad and add listener to it.

Wallet APIs

To Get the virtual currency amount

To Award virtual Currency amount

To Spend Virtual currency amount

Instantiating Native Icon Ads

Instantiation of Native Ad icon

Note: Kindly note that loadAd() cannot be used for Native Icon Ads.

Read more on testing the integration here.