Get started with the Android SDK

Tip:
We're releasing a new version of our Android SDK. Want to get early access and try out the new features?
You can find:
  • Improved support for customers with super apps or separate BI systems
  • Added flexibility for retrieving adid information, higher limits on event deduplication, and improved caching and replaying of information from the SDK
  • Refined information on attribution callbacks, simplified debugging, and more intuitive method names

Click here to complete the application and sign up now! 🚀

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.

Important:
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 an archive

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

Collect App Set Identifier

Note:
The App Set ID is available in Adjust SDK v4.33.5 and above.

The App Set Identifier is a unique identifier that enables you to measure information from any of your apps that a user has installed on their device. All apps by the same developer share the same App Set ID, meaning you can gather meaningful insights from users across all your apps. To record a device's App Set ID, you need to add the following permission to your build.gradle file:

dependencies {
   implementation 'com.google.android.gms:play-services-appset:16.0.2'
}

Step three: add permissions

Note:
If your app targets children, you should remove the AD_ID permission to prevent the Adjust SDK from reading it. See Set up apps for children for instructions.

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 4 methods you can use to gather this information:

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

Meta referrer integration

Samsung referrer plugin

Xiaomi referrer plugin

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.