Android SDK
The Android SDK is currently in beta. Public types under net.linksense.sdk.* may change between 0.x releases. Pin to an exact version in production (implementation("net.linksense:sdk:0.3.0")) and review the changelog before upgrading. We commit to API stability at 1.0.
Overview
The LinkSense Android SDK delivers four capabilities:
- Install-time attribution — match a user's post-install session to the link they tapped before installing your app, including Play Install Referrer when available.
- Deferred deep linking — surface the original link URL via a callback after install.
- App Link forwarding — handle
ACTION_VIEWintents, resolve them for your in-app routing, and report each app open to your LinkSense analytics. - Link CRUD — create, read, update, and delete dynamic links directly from the device.
The SDK has no Google Play Services dependency. The only Play-adjacent code is com.android.installreferrer (AIDL, not GMS). That library is always bundled; enableInstallReferrer = false only stops the SDK from reading it. It does not collect AAID, ANDROID_ID, IMEI, MAC, or the clipboard.
Prerequisites
minSdk24 (Android 7.0)- JVM target 11, Kotlin 2.0+
- Kotlin call sites. The SDK is a Kotlin
objectwithsuspendCRUD functions; from Java you would needLinkSense.INSTANCE, listeners returningUnit.INSTANCE, and a Kotlin wrapper for the CRUD calls - An SDK key from your LinkSense project (open your project's SDK Keys tab)
- App Links configured for your project subdomain (see Android Deep Linking)
Installation
The SDK is published on Maven Central as net.linksense:sdk. Add it to your app module's build.gradle.kts:
dependencies { implementation("net.linksense:sdk:0.3.0")}Make sure mavenCentral() is in your repositories block (it is by default in modern Gradle projects).
Configuration
Configure the SDK in your Application.onCreate() so it's ready before any Activity launches:
import android.app.Applicationimport android.util.Logimport net.linksense.sdk.LinkSenseimport net.linksense.sdk.LinkSenseConfigurationimport net.linksense.sdk.LinkSenseErrorimport net.linksense.sdk.LogLevel class MyApp : Application() { override fun onCreate() { super.onCreate() try { LinkSense.configure( this, LinkSenseConfiguration( sdkKey = "ls_sdk_<project>_<random>", enableInstallReferrer = true, logLevel = LogLevel.OFF, ), ) LinkSense.start() } catch (e: LinkSenseError.InvalidSdkKey) { Log.e("LinkSense", "Malformed SDK key", e) } }}Don't forget to register your Application subclass in AndroidManifest.xml:
<application android:name=".MyApp" ...></application>Configuration fields:
| Field | Type | Required | Description |
|---|---|---|---|
sdkKey | String | Required | Your project SDK key (format: ls_sdk_<project>_<random>). Generate one in your project's SDK Keys tab. |
enableInstallReferrer | Boolean | Optional | Use Google Play Install Referrer for high-confidence attribution. Requires the app to be installed via Play. Default true. |
enableFingerprint | Boolean | Optional | Send the probabilistic fingerprint (IP, user agent, screen, locale) used when no Install Referrer click is available. Default true. |
logLevel | LogLevel | Optional | Diagnostic logging level (OFF, ERROR, INFO, DEBUG). Default OFF — recommended for production. |
Subsequent calls to configure after the first are no-ops by design. The SDK reuses the same install idempotency key across cold starts to prevent double-attribution.
A malformed key throws LinkSenseError.InvalidSdkKey and leaves the SDK unconfigured, so start() does nothing and every CRUD call throws NotConfigured. You can call configure again with a corrected key. Copy the key from the dashboard rather than retyping it.
Handling Deferred Deep Links
Register a handler to receive the original dynamic link URL once attribution resolves. The callback fires on the main thread (Looper.getMainLooper()).
LinkSense.onDeferredDeepLink { uri -> uri?.let { router.handle(it) }}On the first launch after install the listener receives the matched link, or null if no click matched. If /install finds no match right away, the SDK checks again after about 1.5 s and 5 s before giving up, so an organic install gets its null roughly 5 seconds after start(). On every later launch the listener fires with null straight away. Treat null as "nothing to route", not as "organic install": if you need a once-per-install branch, keep your own first-launch flag.
If enableInstallReferrer is true and the app was installed via Google Play, the SDK uses the Install Referrer click id for high-confidence attribution (the referrer read is capped at 5 s). Otherwise it falls back to probabilistic fingerprint matching. A failed /install is retried with backoff and, if still failing, resent on a later launch for up to 24 hours.
Forwarding App Links
When your app is opened via an App Link tap, forward the intent to the SDK. handleIntent returns true when the intent carried a link it handled. On the first launch after install the tap is also used for attribution and the listener receives the matched deep link; after that it receives the tapped URL.
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (savedInstanceState == null) { LinkSense.handleIntent(intent) { uri -> uri?.let { router.handle(it) } } } } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) LinkSense.handleIntent(intent) { uri -> uri?.let { router.handle(it) } } }}Each forwarded link is also reported to LinkSense as an app open, so opens from verified App Links show in your analytics. The report never delays your listener. Forward the launch intent only when savedInstanceState == null, as above: a re-created activity (rotation, process restore) carries the same intent again, and forwarding it would count one open twice.
For Digital Asset Links (assetlinks.json) hosting and the autoVerify intent filter, see Android Deep Linking.
Link CRUD
The SDK exposes createLink(options), getLink(id), updateLink(id, options), and deleteLink(id) as suspend functions. Call them from a coroutine scope. The option and model types (CreateLinkOptions, UpdateLinkOptions, FieldUpdate, Link, LinkMetadataValue) live in net.linksense.sdk.links:
import net.linksense.sdk.LinkSenseimport net.linksense.sdk.LinkSenseErrorimport net.linksense.sdk.links.CreateLinkOptions lifecycleScope.launch { try { val link = LinkSense.createLink( CreateLinkOptions( name = "Summer sale", desktopUrl = "https://example.com/sale", androidFallbackUrl = "https://play.google.com/store/apps/details?id=com.example.myapp", ) ) println("Created: ${link.fullUrl}") } catch (e: LinkSenseError) { println("Failed: $e") }}UpdateLinkOptions uses FieldUpdate<T> with three variants: FieldUpdate.Unchanged (don't send the field, the default), FieldUpdate.Set(value) (send a new value), or FieldUpdate.Clear (explicitly null the field server-side). Clear only compiles for clearable fields; name, tags and iosClipboardEnabled can be set but not cleared. Links you read back expose their custom data as link.metadata.
Error Handling
All CRUD methods throw LinkSenseError — a sealed class mapping server error codes to typed subtypes:
lifecycleScope.launch { try { val link = LinkSense.getLink(linkId) // use link } catch (e: LinkSenseError) { when (e) { is LinkSenseError.NotConfigured -> println("Call configure() first") is LinkSenseError.Network -> println("Network failure: ${e.cause}") is LinkSenseError.RateLimited -> println("Retry after ${e.retryAfterSeconds}s") is LinkSenseError.InvalidInput -> println("Invalid fields: ${e.fieldErrors}") is LinkSenseError.AccessDenied -> println("Plan limit: ${e.currentUsage}/${e.limit} on ${e.plan}") is LinkSenseError.Server -> println("Server ${e.code} (HTTP ${e.status}): ${e.serverMessage}") else -> println("Other error: $e") } }}Subtypes: NotConfigured, InvalidSdkKey, Network, Unauthorized, ForbiddenCrossScope, ForbiddenField, InvalidInput, NotFound, SlugExists, AccessDenied, RateLimited (retryAfterSeconds, may be null), DecodeFailure, Server (carries code, serverMessage and the HTTP status).
AccessDenied is thrown when your plan blocks the call — createLink with no subscription or at the link limit — or when the SDK key isn't allowed on Android. It carries serverMessage, upgradeRequired (false when the server sends no details) and the nullable plan, currentUsage and limit. Server codes without a dedicated subtype arrive as Server with the code string.
Example & Resources
The SDK is published on Maven Central as net.linksense:sdk. Expo and React Native apps use the React Native SDK, which bundles it.