English

Get started with the Android SDK

The Adjust Android SDK enables you to track attribution, events, and much more in your Android app. Follow the steps in this guide to set up your app to work with the Adjust SDK. You can also check out our example apps on GitHub.

Step one: set up your environment

To start using the Adjust SDK, you will need to add it to your project as a dependency.

Note:
The minimum supported Android API level for the Adjust SDK integration is 9 (Gingerbread). The minimum supported Android API level for the web view extension is 17 (Jelly Bean).

Maven

Add as a JAR

Step two: add Google Play Services

Apps in the Google Play Store need to use the Google Advertising ID to identify devices. To enable the Google Advertising ID for our SDK, you need to integrate Google Play Services. To do this, add the Google Play Services library to your project. Add the following dependency to the dependencies section of your build.gradle file.

dependencies {
   implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
}
Note:
The Adjust SDK is not tied to any version of the play-services-analytics dependency. You can use the any version of the Google Play Services library.

Step three: add permissions

The Adjust SDK requires the following permissions. Add them to your AndroidManifest.xml file if they are not already present:

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

If you are not targeting the Google Play Store, you need to add the following permission:

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

Step four: set up Proguard

If you are using Proguard in your application, add the following lines to your Proguard file:

-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
    int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    java.lang.String getId();
    boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }

If you are not publishing your app in the Google Play Store, add the following com.adjust.sdk rule:

-keep public class com.adjust.sdk.** { *; }

Step five: set up install referrer

The install referrer is a unique identifier which you can use to attribute an app install to a source. The Adjust SDK requires this information to perform attribution. There are three methods you can use to gather this information:

  • Use the Google Play Referrer API.
  • Listen for the INSTALL_REFERRER intent with a broadcast receiver.
  • Use the Huawei Referrer API (only for Huawei devices).
Important:
Google has deprecated the INSTALL_REFERRER intent method of delivering referrer information for Google Play Services. If you are currently using this method, please migrate to the Google Play Referrer API.

Google Play Referrer API

INSTALL_REFERRER intent

Huawei Referrer API

Step six: integrate the SDK into your app

If you are integrating the Adjust SDK into a standard app, follow the Standard SDK setup steps. If you are integrating the SDK for web views, follow the Web Views SDK setup steps.

Standard SDK

Web View SDK

Step seven: set up session tracking

You need to set up session tracking so that the SDK can pass session information to the Adjust backend. Follow the instructions below to set this up in your app.

API level 14 and higher

API level 9 to 13

Step eight: set up logging

To set the verbosity of logging, call the setLogLevel method on your config instance.

Java
Javascript
adjustConfig.setLogLevel(LogLevel.WARN);

If you want to disable all logging, set the log level to suppress:

Java
Javascript
AdjustConfig config = new AdjustConfig(this, appToken, environment, true);
config.setLogLevel(LogLevel.SUPRESS);
Adjust.onCreate(config);

Step nine: build your app

Well done! You should now be able to build and run your app. Enable logging to check for any issues. You are ready to start attributing your users with the Adjust SDK.