Android SDK
Install and integrate the LinkTrail Android SDK — package io.linktrail, minSdk 26.
Binary AAR · package io.linktrail · entry point LinkTrail · minSdk 26 · artifact io.linktrail:sdk:0.0.3 on Maven Central.
Install
The SDK is published to Maven Central, so no custom repository is needed — just add the dependency:
dependencies {
implementation("io.linktrail:sdk:0.0.3")
}mavenCentral() is already in the default repositories of every Android project, which also resolves the SDK's transitive dependencies (coroutines, Play Install Referrer, App Set ID). Keep google() alongside it.
Nothing else to configure: the INTERNET permission merges in from the SDK's manifest, and consumer ProGuard/R8 rules are bundled in the AAR — no app-side keep rules needed.
Integrate
import io.linktrail.LinkTrail
// In Application.onCreate(). The API key is required — a blank key throws.
// The install is tracked automatically.
LinkTrail.configure(context = this, apiKey = "lt_live_...")
// One hook — fires for deferred (first-launch) AND re-engagement links:
LinkTrail.shared?.onLink { link, source ->
router.route(link.path, link.customData)
}
LinkTrail.shared?.onError { error -> /* e.g. LinkTrailError.InvalidApiKey */ }Forward incoming links from your Activity — both entry points:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
LinkTrail.shared?.handleDeepLink(intent?.data)
}
override fun onNewIntent(intent: Intent) { // app already running
super.onNewIntent(intent)
setIntent(intent) // keep getIntent() current
LinkTrail.shared?.handleDeepLink(intent.data)
}Every callback API also has a coroutine suspend twin (trackInstallAsync, handleDeepLinkAsync, trackEventAsync). Callbacks are delivered on the main thread.
More
// Custom + revenue events:
LinkTrail.shared?.trackEvent("purchase", value = 59.99, currency = "USD")
// Cached results:
val attribution = LinkTrail.shared?.lastAttribution
val lastLink = LinkTrail.shared?.lastDeepLink
// Attribution hook (fires when an install is attributed):
LinkTrail.shared?.onAttribution { attribution -> /* … */ }
// Consent-gated install (defer configure's auto-track, then call manually):
LinkTrail.configure(context = this, apiKey = "lt_live_...",
options = LinkTrailOptions(autoTrackInstall = false))
LinkTrail.shared?.trackInstall()Options & defaults
| LinkTrailOptions field | Default | Notes |
|---|---|---|
| logEnabled | false | Master switch for SDK logging (tag: LinkTrail) |
| logLevel | INFO | DEBUG · INFO · WARNING · ERROR · NONE |
| requestTimeoutMillis | 15 000 | Per-request network timeout |
| retryPolicy | DEFAULT | 3 attempts, 500 ms base / 8 s max backoff; DISABLED turns retries off |
| linkDomains | empty (all hosts) | Exact host or subdomain match; see warning under Deep-link setup |
| autoTrackInstall | true | false = consent-gated; call trackInstall() yourself |
Errors are a sealed LinkTrailError: MissingApiKey (thrown synchronously by configure), InvalidApiKey (the backend rejected the key — arrives via onError, not from configure), NotALinkTrailUrl, InvalidUrl, Server, Transport, Decoding, EmptyResponse. Under the hood the SDK also queues failed events offline and retries them after the next successful install call, and handles the Play Install Referrer and App Set ID automatically — there's no API to call. (App Tracking Transparency / SKAdNetwork are iOS-only and have no Android equivalent.)
API surface
| API | Purpose |
|---|---|
| configure(context, apiKey, options) | Initialize; auto-tracks the install |
| onLink { link, source } | Deep link delivered (deferred + re-engagement) |
| onAttribution { attribution } | Install attribution result |
| onError { error } | Failures (invalid key, network…) |
| handleDeepLink(uri) | Forward App Links / custom schemes |
| trackEvent(name, value, currency) | Custom + revenue events |
| trackInstall(force) | Manual install track (with autoTrackInstall = false) |
| lastAttribution / lastDeepLink | Cached last results |
| trackInstallAsync / handleDeepLinkAsync / trackEventAsync | Coroutine suspend twins |
Deep-link setup
Declare your App Links host (plus an optional custom scheme) in the manifest:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="yourapp.linktrail.io" />
</intent-filter>