Android Integration (Kotlin)
Embed the AR SDK in a native Android app using Unity as a Library (UaaL) and drive it from Jetpack Compose/Views. A thin, type-safe facade (TreedisARSDK) exposes the same commands and events as the web bridge — see the AR SDK Overview for the shared concepts.
What you receive
The SDK is not a single file — it is the Unity AR engine compiled as an embeddable library plus a small Kotlin facade. You receive one package, TreedisARSDK-Android, containing:
| Item | What it is | What to do with it |
|---|---|---|
unityLibrary module (or unityLibrary-release.aar + its dependency AARs) |
The compiled AR engine + bundled AR assets (the large artifact — the actual product). The com.treedis.arsdk.ArSdkBridge shim is already inside it. |
Include as a Gradle module/dependency and host UnityPlayer in an Activity/Fragment per Unity's UaaL host setup. |
treedis-arsdk (Kotlin) |
The type-safe facade you call from Kotlin | Add as a module/dependency (or drop the source into your app). |
You do not need Unity installed to use the SDK — you only build against the prebuilt library.
Versioning: the engine library and the facade are released together. When you upgrade, replace both from the same release so the protocol stays in sync.
How it works
The facade does the same JSON marshalling the web bridge does, and forwards messages into the embedded Unity engine:
- Commands (Kotlin → SDK): the facade builds the
{ type, data }envelope and delivers it to Unity viaUnityPlayer.UnitySendMessage. - Events (SDK → Kotlin): Unity emits a
{ event, args }envelope that the facade decodes and dispatches to yourTreedisARSDKListeneron the main thread.
Setup
After the Unity library is loaded, register the listener and drive the SDK:
import com.treedis.arsdk.TreedisARSDK
import com.treedis.arsdk.TreedisARSDKListener
TreedisARSDK.listener = object : TreedisARSDKListener {
override fun onLocalizationChanged(isLocalized: Boolean) {
// Update your UI when tracking is established/lost.
}
override fun onARObjectClicked(id: Int, type: String) {
// Present native detail UI for the tapped object.
}
override fun onNavigationComplete() {
showToast("You have reached your destination!")
}
// Catch-all for events without a dedicated callback.
override fun onEvent(name: String, args: org.json.JSONArray) {
Log.d("ARSDK", "event $name $args")
}
}
TreedisARSDK.start()
// Initialization sequence (set window size, environment, tour, then localize):
TreedisARSDK.setWindowSize(width = view.width, height = view.height)
TreedisARSDK.setEnvironment("Production") // or "Stage"
TreedisARSDK.setTourInfo(slug = "your-tour-slug", matterId = "your-matter-id")
TreedisARSDK.startLocalization()
Common commands
TreedisARSDK.showARObject(id = 123, type = "TAG")
TreedisARSDK.hideARObject(id = 123, type = "TAG")
TreedisARSDK.startNavigation(destinationName = "Conference Room A", x = 1.0, y = 0.0, z = 4.5)
TreedisARSDK.stopNavigation()
TreedisARSDK.confirmTeleport()
TreedisARSDK.endTeleport()
TreedisARSDK.clickCoords(x = 180.0, y = 320.0)
// Escape hatch for any command not wrapped in a typed method:
TreedisARSDK.send("setThreadCompleted",
org.json.JSONObject().put("threadId", 7).put("isCompleted", true))
Command & event reference (Kotlin)
The facade covers the full protocol. The most common mappings:
Protocol type / event |
Kotlin |
|---|---|
setEnvironment |
setEnvironment(environment, customApiUrl?, customCdnUrl?) |
setTourInfo |
setTourInfo(slug, matterId) |
windowSize |
setWindowSize(width, height) |
startLocalization |
startLocalization() |
manualRelocalize |
manualRelocalize() |
startNavigation |
startNavigation(destinationName, x, y, z) |
stopNavigation |
stopNavigation() |
teleportConfirm / teleportEnd |
confirmTeleport() / endTeleport() |
showARObject / hideARObject |
showARObject(id, type) / hideARObject(id, type) |
clickCoords |
clickCoords(x, y) |
stopAR |
stopAR() |
| (any other) | send(type, data) |
event onLocalizationStatusChanged |
onLocalizationChanged |
event onNavigationComplete |
onNavigationComplete |
event onNavigationTeleport |
onNavigationTeleport |
event onNavigationDistance |
onNavigationDistance |
event onARObjectClick |
onARObjectClicked |
| event (loading/threads/other) | onEvent (catch-all) |
The AR object type strings (TAG, VS_IMAGE, VS_VIDEO, VS_OBJECT, VS_HTML, POLYGON, THREAD) are listed on the AR SDK Overview page.

