Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Analytics-Kotlin FAQ


What is the latest version of the library?

what-is-the-latest-version-of-the-library page anchor

Analytics-Android is published to Maven Central(link takes you to an external page) where you can see all published releases.


Where is the changelog for the library?

where-is-the-changelog-for-the-library page anchor

You can see a changelog in the GitHub repository(link takes you to an external page), detailing the changes made in each release.


Can I use the library with Maven?

can-i-use-the-library-with-maven page anchor

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.kotlin</groupId>
3
<artifactId>android</artifactId>
4
<version>1.10.1</version>
5
</dependency>

How big is the Segment SDK?

how-big-is-the-segment-sdk page anchor

The core Segment SDK is extremely lightweight. The JAR weighs in at 12.3KB.


How should I configure Proguard?

how-should-i-configure-proguard page anchor

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.


Do you support Phonegap or Cordova?

do-you-support-phonegap-or-cordova page anchor

Yes. You can use Segment's browserify'd analytics-node(link takes you to an external page) package just like any other client-side JavaScript library.


Can I use the library in Java?

can-i-use-the-library-in-java page anchor

Yes. Please refer to the Java Compatibility(link takes you to an external page) doc for sample usages.


My app crashes with NoClassDefFoundError Failed resolution of: Ljava/time/Instant

my-app-crashes-with-noclassdeffounderror-failed-resolution-of-ljavatimeinstant page anchor

If you're on a version prior to 1.10.4, the SDK internally uses a number of Java 8 language APIs through desugaring (see Java 8+ API(link takes you to an external page) desugaring support). Please make sure your project either uses Android Gradle plugin 4.0.0 or higher, has a minimum API level of 26, or is upgraded to the latest SDK.


Will I still see device-mode integrations listed as false in the integrations object?

will-i-still-see-device-mode-integrations-listed-as-false-in-the-integrations-object page anchor

When you successfully package a plugin in device-mode, you will no longer see the integration listed as false in the integrations object for a Segment event. This logic is now packaged in the event metadata, and is not surfaced in the Segment debugger.


What is the instanceId set in context?

what-is-the-instanceid-set-in-context page anchor

The instanceId was introduced in V 1.10.1(link takes you to an external page) and correlates events to a particular instance of the client in a scenario when you might have multiple instances on a single app.


How should I configure my proxy URL?

how-should-i-configure-my-proxy-url page anchor

To proxy events to Segment's API, you can configure your proxy URL via the requestFactory setting:

1
Analytics(BuildConfig.SEGMENT_WRITE_KEY, androidContext()) {
2
trackApplicationLifecycleEvents = true
3
defaultSettings = Settings(
4
integrations = emptyJsonObject
5
)
6
requestFactory = object : RequestFactory() {
7
8
override fun settings(cdnHost: String, writeKey: String): HttpURLConnection {
9
return super.settings("cdn-segment.test.com/v1", writeKey)
10
}
11
12
override fun upload(apiHost: String): HttpURLConnection {
13
return super.upload("api-segment.test.com/v1")
14
}
15
}
16
}

When proxying your events, you must forward the batched events to https://api.segment.io/v1/b. The https://api.segment.io/v1/batch endpoint is reserved for events arriving from server side sending, and proxying to that endpoint for your mobile events may result in unexpected behavior.