Skip to content

Latest commit

 

History

History
83 lines (57 loc) · 3.05 KB

Android_README.md

File metadata and controls

83 lines (57 loc) · 3.05 KB

Cocos2dX Android Integration Guide

Integration:

How to integrate the AppsFlyer SDK into your Cocos2d-x Android project.

1. Add the SDK to your 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-to-android-mk

2. Add the C++ source file definitions

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.cpp

add-android-files

For 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
     )

add-android-files

3. Add the AppsFlyer library to your project

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.

4. Add permissions

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" />

The AD_ID permission for android apps

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.