Dash Stats Docs

SDK setup

Create an AppBrain developer account to get access to the AppBrain developer dashboard and to register your app for the SDK.

Adding AppBrain to your project

Add the AppBrain repository and dependency to your Gradle build file:

repositories {
    maven {
        url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
    }
}

dependencies {
    compile 'com.appbrain:appbrain-sdk:[email protected]'
}

The above configuration should not be in the buildscript section of your project’s build file. To build against a fixed version of the SDK, replace the + with the version number you want to use.

Make sure your integration follows our policies. Please contact us directly at contact@appbrain.com if you need any assistance, and we will be happy to help you.

Migrating or manual setup

If you are migrating to Gradle or updating your project from the AppBrain JAR to AAR, please make sure to:

  • Remove the outdated AppBrain JAR file if it’s still in your libs/ folder.
  • Remove the AppBrain sections from your AndroidManifest.xml and ProGuard configuration. (If you use the AppBrain AAR library, these are automatically merged)

If you don’t use Gradle, you can also manually add the SDK to your project. See: Manual setup.

Initializing the SDK

The AppBrain SDK is initialized automatically when your app starts. For AppBrain analytics, a user is counted as active every time an Activity is created. If users interact with your app outside of an Activity class somehow, you can manually initialize AppBrain from your code by calling AppBrain.init().

It is recommended to use AppBrain in test mode while developing your app, preferably before your Activity.onCreate():

@Override
protected void onCreate(Bundle savedInstanceState) {
    AppBrain.addTestDevice(myTestDeviceId);
    super.onCreate(savedInstanceState);
}

The device ID required by addTestDevice() can be found in your logcat output under the tag “AppBrain”.

COPPA compliance

If your app falls under the Children’s Online Privacy Protection Rule (COPPA, see COPPA FAQ for more information), you can enable the COPPA compliance mode by adding the following line to your AndroidManifest.xml inside the <application> tag:

<meta-data
    android:name="appbrain.child_directed"
    android:value="true" />

For additional information and instructions for more fine-grained control, please refer to the COPPA compliance section.

JobService job ID

The AppBrain SDK uses an Android JobService to run certain background tasks efficiently. When scheduling this JobService, the AppBrain SDK by default uses a job ID with value "AppBrain".hashCode() (i.e. 1205629301).

Job IDs need to be unique within an app, so it can happen that you run into a problem because our ID conflicts with an ID that is used in your app already. To solve this situation, you can configure the AppBrain SDK to use a different job ID from the AndroidManifest. Add the following tag inside your <application> tag:

<meta-data
    android:name="appbrain.job_id"
    android:value="1205629301" />