Analytics-Android frequently asked questions
End-of-Support for Analytics-Android in March 2026
End-of-support for the Analytics-Android SDK is scheduled for March 2026. Segment's future development efforts concentrate on the new Analytics-Kotlin SDK. If you'd like to upgrade to Analytics-Kotlin, see the migration guide.
Analytics-Android is published to Maven Central where you can see all published releases.
You can see a changelog in the GitHub repository, detailing the changes made in each release.
Yes! You can use the Segment library with Maven, or any other custom build system because the core SDK is simply a JAR.
1<dependency>2<groupId>com.segment.analytics.android</groupId>3<artifactId>analytics</artifactId>4<version>LATEST</version>5</dependency>
The core Segment SDK is extremely lightweight. It contains just under 1k methods, the JAR weighs in at 123KB and the dex size is 113KB.
If you're using Gradle and build flavors, you can provide an analytics.xml for each configuration with different Writekeys in each.
For other cases, you can also construct custom instances of the client and pass in a different key for each instance. Set it as the singleton instance, and use the same API everywhere else.
1class MyApp extends Application {2@Override public void onCreate() {3Analytics analytics;4if(BuildConfig.DEBUG) {5analytics = new Analytics.Builder(this, debugWriteKey)...build();6} else {7analytics = new Analytics.Builder(this, releaseWriteKey)...build();8}9Analytics.setSingletonInstance(analytics); // Must be called before any calls to Analytics.with(context)1011// Now Analytics.with will return the custom instance12Analytics.with(this).track("App Launched");13}14}
...for example, Mixpanel's push notifications?
If you're using Device-mode for a mobile destination, meaning that you are bundling the destination's mobile SDK, you can always access features from that tool's native SDK.
To make sure you use the same instance of these destinations as Segment does, you can register a listener that notifies you when the destinations are ready. This listener is called synchronously if the destinations are notified, and asynchronously if the destinations aren't yet ready.
1analytics.onIntegrationReady("Crittercism", new Callback() {2@Override public void onReady(Object instance) {3// Crittercism uses static methods only, so the instance returned is null.4Crittercism.leaveBreadcrumb();5}6});7analytics.onIntegrationReady("Mixpanel", new Callback() {8@Override public void onReady(Object instance) {9MixpanelAPI mixpanelAPI = (MixpanelAPI) instance;10mixpanelAPI.clearSuperProperties();11}12});
Destinations that return Void use a shared instance, and you can call into the SDK directly. This API guarantees that the destinations are initialized first. If you ever decide to change the settings for the destination from the Segment App, the changes are reflected here.
1analytics.onIntegrationReady(BundledIntegration.FLURRY, new Callback() {2@Override public void onReady(Object instance) {3// Flurry uses static methods only, so the instance returned is null.4Flurry.setLogEnabled(true);5}6});
If you use the destination callbacks described above, and don't receive a callback, check your Proguard configuration. Any easy way to verify that Proguard is the issue is to disable it completely for a run and see if the callbacks is invoked.
For the Segment SDKs, you can add the following snippet to your Proguard configuration:
1-keep class com.segment.analytics.** { *; }2-keep class androidx.lifecycle.DefaultLifecycleObserver
You should also check the vendor documentation for any Device-mode destinations you are bundling, to see if they include any recommended Proguard configurations.
Outbound isn't a Device-mode destination, so you must set it up manually.
First, set up the GCM client as described in the instructions.
The Segment servers look for a context.device.token key to send to Outbound. If you are using Analytics-Android version 2.1.6 or later, you can then set the registration ID from the step above on the context, as in the example below:
analytics.getContext().putDeviceToken(registrationId);
The entire code flow looks a bit like this:
1String registrationId = loadRegistrationId(); // look up a cached value2if(registrationId == null) {3registrationId = register(SENDER_ID); // using GoogleCloudMessaging4save(registrationId); // save the registration ID5}6analytics.getContext().putDeviceToken(registrationId);
Yes! You can use Segment's browserify'd analytics-node package just like any other client-side JavaScript library.
No, there hasn't been any instances that show there are limitations when Segment tracks Huawei devices.
No. It depends on androidx-startup for initialization, this snippet prevents the Segment SDK from tracking app lifecycle events.
The solution is to either remove the snippet completely or use tools:node="merge" instead of tools:node="remove".
1<provider2android:name="androidx.startup.InitializationProvider"3android:authorities="${applicationId}.androidx-startup"4tools:node="merge"></provider>