#ApplovinX A C++ wrapper of Applovin for Cocos2d-X. Supports Android and iOS.
#Environment
-
###Applovin SDK
- Android: v5.2.2
- iOS: v2.2.4
-
###cocos2d-x
- cocos2d-x-2.0.3 or higher
#Example Project
- iOS: example/proj.ios/HelloCpp.xcodeproj
- Android: example/proj.android
You need to change the build script (such as build_native.sh) according to your own environment before compiling.
#Add to Your Own Project
iOS and Android will share the same ApplovinX.h
header file. You need add applovin-x/ApplovinX.h
to your Classes
folder in the beginning.
All the following files you need in iOS are in applovin-x/ios
fold.
- Add the previous
ApplovinX.h
to your Xcode project - Add
headers/
,ApplovinX_ios.mm
,libAppLovinSdk.a
to your Xcode project - Add
#import "ALSdk.h"
toAppController.mm
, and call[ALSdk initializeSdk];
in AppController'sapplicationDidFinishLaunching
method - Go to your Project Settings. Select "Info", right-click on one of the rows of "Custom iOS Properties" and select "Add Row". The key of the new row should be AppLovinSdkKey and the value shouble be YOUR_SDK_KEY
- Ensure you're linking with the following libraries:
- AdSupport.framework
- CoreTelephony.framework
- CoreGraphics.framework
- MediaPlayer.framework
- StoreKit.framework
- SystemConfiguration.framework
- UIKit.framework
- Go to your Project Settings. Select "Build Settings", search for "Other Linker Flags" and add -all_load -ObjC.
All the following files you need in Android are in applovin-x/android
fold.
-
Add the package
com.wenbin.ApplovinX
and itsApplovinXBridge.java
to your Eclipse project. (You can just add the wholecom
fold tosrc
fold in Eclipse project, and refresh in Eclipse) -
Add
applovin-sdk-5.1.0.jar
as an external jar to your project. (You can just add theapplovin-sdk-5.1.0.jar
file tolibs
fold in Eclipse project, and refresh in Eclipse) -
Add
ApplovinX_android.cpp
,ApplovinXJni.cpp
andApplovinXJni.h
to yourjni
fold. -
Add
ApplovinX_android.cpp
,ApplovinXJni.cpp
to your jni'sAndroid.mk
. -
In the java implementation of your main activity (which should have been created by the Cocos2d-X script),
import com.wenbin.ApplovinX.*;
-
At the beginning of
onCreate(Bundle savedInstanceState)
, right aftersuper.onCreate(savedInstanceState)
, add the following code:ApplovinXBridge.initApplovinXBridge(this);
-
Add the following xml to your Android Manifest file:
Add Sdk Key. This needs to go inside the "application" tag:
<meta-data android:name="applovin.sdk.key" android:value="YOUR_SDK_KEY" />
Add permission:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Add activity:
<activity android:name="com.applovin.adview.AppLovinInterstitialActivity" />
##Email: [email protected] ##Blog: http://geeksavetheworld.com
##You're welcome to contribute. ;-)