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 {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // While testing call AppBrain.addTestDevice() here.
        AppBrain.init(this);
    }
}

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:

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