How to integrate the AppsFlyer SDK into your Cocos2d-x Android project.
Throughout this guide, we assume that you are using Android Studio for development.
Take the files from the AppsFlyer folder and add them to your Android project under Classes folder.
Add the paths of the AppsFlyer C++ files to the LOCAL_SRC_FILES section in your Android.mk file if you use PROP_BUILD_TYPE=ndk-build
../../../Classes/AppsFlyer/AppsFlyerXAndroid.cpp \
../../../Classes/AppsFlyer/AppsFlyerProxyX.cpp \
../../../Classes/AppsFlyer/AppsFlyerX.cppFor cmake a.e. PROP_BUILD_TYPE=cmake use:
For example in CMakeLists.txt:
# add cross-platforms source files and header files
list(APPEND GAME_SOURCE
Classes/AppsFlyer/AppsFlyerX.cpp
Classes/AppsFlyer/AppsFlyerXAndroid.cpp
Classes/AppsFlyer/AppsFlyerProxyX.cpp
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
)
list(APPEND GAME_HEADER
Classes/AppsFlyer/AppsFlyerX.h
Classes/AppsFlyer/AppsFlyerXAndroid.h
Classes/AppsFlyer/AppsFlyerProxyX.h
Classes/AppDelegate.h
Classes/HelloWorldScene.h
)We prefer to use gradle - as the easiest way to stay up to date. Please add the following lines to your gradle app dependencies:
implementation 'com.appsflyer:af-android-sdk:6.13.0'
For Google Install Referrer, please, add also:
implementation 'com.android.installreferrer:installreferrer:2.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
As alternative way, take the latest AF-Android-SDK.jar library and copy it to your project's libs folder.
In the Package Explorer, open the AndroidManifest.xml file of your Android project. Add the uses-permission tag for INTERNET if it's not already present.
<uses-permission android:name="android.permission.INTERNET" />In v6.8.0 of the AppsFlyer SDK, we added the normal permission com.google.android.gms.permission.AD_ID to the SDK's AndroidManifest, to allow the SDK to collect the Android Advertising ID on apps targeting API 33. If your app is targeting children, you may need to revoke this permission to comply with Google's Data policy. You can read more about it here.


