Cocos Analytics Android SDK Access Guide

SDK Download

Import SDK

Merge the SDK jar package to the build path of the target project.

Eclipse ADT 17 or Above

For users using Eclipse ADT 17 or above, please create a folder named libs in the project directory, copy the .jar package directly to this folder, and then refresh the project in Eclipse.

Eclipse ADT 17 or Lower

For users using Eclipse ADT 17 or lower, right-click the project root directory, select Properties -> Java Build Path -> Libraries, and then click Add External JARs..., select the path to the .jar and click OK.

Android Studio Access

Put the .jar file in the libs directory and add the compile field in the corresponding location of the build.gradle file:

dependencies {
    compile files('libs/libcocosanalytics.jar')

Add Permissions

Add attributes in the manifest tag of the AndroidManifest.xml file

<manifest …="">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application ...>

Privilege Description:

Privilege Usage
android.permission.INTERNET (required) Send logs to our server
android.permission.ACCESS_NETWORK_STATE (required) Detect device network status
android.permission.ACCESS_FINE_LOCATION (optional) Get the user's geographic location

SDK Initialization

Currently, the SDK only provides initialization by code. Please call the initialization interface in the onCreate() of the entry activity. The interfaces are as follows:

    Context context,
    String appID,       // game ID
    String storeID,     // distribution channel
    String engine,      // game engine default "Cocos"

Finally, onResume() and onPause() in all activities (including entry activities) need to call interfaces:

public void onResume() {
public void onPause() {

Local Debugging

The SDK also provides CAAgent.enableDebug(boolean) to enable/disable local log output. After successful debugging, set to False or remove this method. All tags of SDK logs are Cocos Analytics.

results matching ""

    No results matching ""