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

To use the AppBrain SDK, you need to make sure it is initialized by calling AppBrain.init() in all Activity classes where you use the SDK:

import com.appbrain.AppBrain;

public class ExampleActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        // While testing call AppBrain.addTestDevice() here.

It is recommended to use AppBrain in test mode while developing your app. To put the SDK in test mode call AppBrain.addTestDevice() before calling AppBrain.init(). The device ID required by addTestDevice() can be found in your logcat output when calling AppBrain.init().

As an alternative, it’s also possible to initialize from your Application class by calling AppBrain.initApp() instead. This can be useful when you would like to use methods of the SDK outside of an Activity, for example in a background service. Note however that using AppBrain.initApp() will not give you proper analytics. Only calling AppBrain.init() in Activity.onCreate() will result in correct statistics on the developer dashboard.

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:

    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:

    android:value="1205629301" />