Android SDK

The Kotlin SDK supports Android API 24+, Play Billing 8, signed device sessions, encrypted durable queues and subject-scoped entitlement caching.

The source is private for now and a public release is pending, so there is no public install command yet.

Configure

kotlin code
val sdk = SubHero.configure(
    context = applicationContext,
    projectId = projectId,
    publishableKey = publishableKey,
    apiOrigin = apiOrigin,
    appVersion = appVersion,
    onPending = { /* Pending store approval: do not grant access. */ },
    onFailure = { /* Show generic failure; never log receipts or tokens. */ },
    onEventRejected = { result -> /* Surface rejected analytics events. */ },
)
sdk.start()
val products = sdk.products()
val paywall = sdk.paywall("main")
sdk.paywallShown(paywall) // Only when actually presented.
sdk.purchase(activity, products.first(), selectedOfferToken, paywall)

SubHero is the Kotlin facade alias for AndroidSubHero. Runtime catalog reads exclude history-derived and retired products and select the known session’s platform. Product details, localized prices and offer eligibility come from Play Billing. In the console, open the project’s Products → Paywalls editor. As an administrator, create main, select and order sellable catalog products, enter public remote-config JSON, and enable the placement. Use a placement ID beginning with a letter or digit. Remote config is limited to 16 KiB and is readable by app users: never include secrets. Disabled or missing placements return 404. The host chooses an eligible offer deliberately. Enable core-library desugaring in consuming API 24/25 apps as shown by the example module.

Identity, events and access

kotlin code
sdk.identify(identityJwtFromYourBackend)
val access = sdk.entitlements(forceRefresh = true)
sdk.track("article_read", JSONObject().put("category", "news"))
sdk.setDeviceIds(mapOf("app_instance_id" to realFirebaseId), consentGranted = consent)
sdk.restore()
sdk.logout()

Only publishable keys belong in apps. The partner backend issues identity JWTs. Account-change barriers clear grants before waiting on in-flight requests. Late callbacks keep their original binding owner; anonymous work moves only after a confirmed merge. Observe entitlementChanges for grants and call close() when the host releases the client.

Events retain UUIDs and originating subject across restart, batch at 20 items/every 10 seconds, and honor Retry-After. Register custom names before tracking. The queue rejects overflow at 1000 events/1 MiB. First launch needs a signed server session before an event can acquire a subject; an established subject can queue offline after session expiry. Consent false clears analytics IDs. Firebase IDs are supplied by Firebase, never generated by this SDK.

Acknowledgment and validation

The server acknowledges persisted Play purchases, bound or unbound. The device acknowledges only bound:true or owner:other; unknown-token and 409 results never trigger device acknowledgment. Temporary failures retain proofs for retry. A 409 is terminal locally, not a grant. Store-local purchases are exposed separately from server account entitlements.

The companion includes a runnable sandbox APK, fake-store/HTTP tests, Dokka generation support and local Maven staging; a published Dokka reference remains pending. Configure the example with a sandbox project/key at runtime. Verify pending purchases, renewals, process death, restore, acknowledgment recovery and account switching on a real Play test track before production rollout. Namespace verification, package signing and publication remain owner release actions.

Authentication · API reference · Migration guides