Android > SDK integration

Initial setup

Adding permissions

Batch is compatible with Android 4.0.3 (API Level 15) and higher.

Batch requires only one permission: Internet access. You need to ensure you have it in your manifest otherwise Batch will not start correctly.

<uses-permission android:name="android.permission.INTERNET" />

Batch performs better with the Google Play Services library, which improves user targeting. We strongly recommend that you include it in your project in order to enhance offer delivery.

To include the library, follow Google's instructions: How to include Google Play Services library.

If you use the modular Play Services, you will need the following modules:

  • base
  • gcm (for Batch Push: version 9.2 or higher)
  • ads (for Batch Unlock: optional, but improves reliability of the restore feature)

Batch will log a warning if you don't have Google Play Services included in your app.

Integrating the SDK

Complete your build.gradle file:

compile ''

Exact version numbers can be found in the changelog

React Native users

While we don't have an official SDK for React Native, Batch works well in Native Android modules!

Your first start

You are now ready to implement the main functions of Batch setConfig, onStart, onStop, onDestroy, and onNewIntent into all of your activities. A nice way to do so is to make a base activity that all of your activities will extend, and implement Batch here.

The setConfig function should be called only once during your application lifetime to set up the SDK. If you work with one activity, you can add it to the onCreate of that Activity, otherwise the onCreate of your Application will function properly as well.

If you don't integrate Batch in ALL of your activities, we cannot guarantee that all features will work properly.

In your Application:

public class YourApp extends Application
    public void onCreate() 

        Batch.setConfig(new Config(YOUR_API_KEY));

YOUR_API_KEY is your Batch Dev or Live API key. You'll find the API keys needed to set up the SDK in ⚙ Settings → General:

  • Dev API key: Use it for development or testing purposes. This API key won't trigger stats computation. Please take care not to ship an app on a Store with this API key.
  • Live API key: Should be used in a production environment only and in the final version of your app on the Store.

In a BaseActivity:

// This class is an hypothetic class that all your activities should extend: this is not only your first activity.
// It will usually extend AppCompatActivity rather than Activity
public class BaseActivity extends Activity
    protected void onStart()


    protected void onStop()


    protected void onDestroy()


    protected void onNewIntent(Intent intent)
        Batch.onNewIntent(this, intent);


If you're having trouble integrating the SDK, check our troubleshooting documentation.

Testing your integration

Congratulations on finishing the bulk of the integration!

If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in your logcat in devmode. After deploying a build to your device, access the logcat through your preferred method, although using Android Studio's method is quite simple:

Batch is running in dev mode (your API key is a dev one)