---
title: "ClikaRtAndroid"
sidebar_label: "ClikaRtAndroid"
description: "Kotlin binding reference: ClikaRtAndroid."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[ClikaRtAndroid](index.md)

# ClikaRtAndroid

[android]\
object [ClikaRtAndroid](index.md)

The Android entry over [ClikaRt](../ClikaRt/index.md): pins the runtime's cache root to the app's own cache directory, then loads the binding.

The runtime keeps small per-device records (the evidence its GPU probes leave behind, so a driver fault is not repeated on the next start) under the first writable root of `XDG_CACHE_HOME`, then, on Android, the app's own cache directory as the runtime derives it from the process's package name, then `HOME/.cache`, then the temp directory. [load](load.md) sets `XDG_CACHE_HOME` to Context.getCacheDir before the runtime library initializes, so the root is the platform's own answer for this app, first in that order and independent of how the process is named (a process whose name is not its package name, or one with no readable name, would otherwise fall past the Android rung); the records then live where the app's other cache files do (cleared with them by the platform and by the user).

Call [load](load.md) before any other member of the binding (the first touch of [ClikaRt](../ClikaRt/index.md) loads the runtime library). The pin is idempotent, and a value already set for `XDG_CACHE_HOME` (by the host app, or by an earlier pin) is kept as it is.

[load](load.md) also places the runtime's license credential when the app passes one. The runtime reads `CLIKA_RT_LICENSE` from its own process, and an Android app has no shell and no per-user license file to set it from, so the `license` argument sets the variable before the binding loads. An explicit value replaces one already present; `null` (the default) leaves the environment as it is. The credential's text is never logged.

The CPU worker count, `CLIKA_RT_NUM_THREADS`, is read once at the first compute: an app that sets it does so in its own process (`Os.setenv`) before [load](load.md). A phone with a few large cores and several small ones runs best at the large cores' count; measure on the device.

[load](load.md) then hands the runtime this app's state: the application Context, through which the runtime reads the Android facts only the framework exposes (the per-device identity a license binds). The Context itself never leaves the process.

This file lives in an Android-only source directory (`src/main/kotlin`): the desktop module compiles `src/main/java` alone, and `android.system.Os` has no desktop counterpart.

## Properties

| Name | Summary |
|---|---|
| [isTrimRegistered](isTrimRegistered.md) | [android]<br>@[JvmStatic](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-static/index.html)<br>val [isTrimRegistered](isTrimRegistered.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True once [trimOnMemoryPressure](trimOnMemoryPressure.md) has registered its listener. |

## Functions

| Name | Summary |
|---|---|
| [bridgeLogs](bridgeLogs.md) | [android]<br>@[JvmStatic](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-static/index.html)<br>@[JvmOverloads](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-overloads/index.html)<br>fun [bridgeLogs](bridgeLogs.md)(tag: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) = TAG, level: [LogLevel](../LogLevel/index.md) = LogLevel.INFO)<br>Route the runtime's log lines to logcat under [tag](bridgeLogs.md), at the runtime's own severity (trace and debug as Log.DEBUG, info / warn / error as their logcat twins), and set the runtime's threshold to [level](bridgeLogs.md) (the default keeps info and above). Call it after [load](load.md); a second call replaces the sink. |
| [load](load.md) | [android]<br>@[JvmStatic](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-static/index.html)<br>@[JvmOverloads](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-overloads/index.html)<br>fun [load](load.md)(context: Context, license: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)? = null)<br>[pinCacheRoot](pinCacheRoot.md), place [license](load.md) when given, then [ClikaRt.load](../ClikaRt/load.md): one call readies the binding on Android. [license](load.md) is the runtime's license credential (the `CLIKA1-...` text, or the path of a file holding it): a non-null value is set as `CLIKA_RT_LICENSE` for this process before the binding loads, replacing a value already present, and `null` leaves the environment as it is. Without a valid credential the runtime's calls fail ([ClikaRtException.codeName](../ClikaRtException/codeName.md)`LICENSE_FAILED`, or `LICENSE_EXPIRED` for a license past its end date). While the license server cannot be reached they fail with `LICENSE_SERVER_UNREACHABLE` instead, and succeed again once the server answers. |
| [pinCacheRoot](pinCacheRoot.md) | [android]<br>@[JvmStatic](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-static/index.html)<br>fun [pinCacheRoot](pinCacheRoot.md)(context: Context)<br>Set `XDG_CACHE_HOME` to Context.getCacheDir for this process unless the variable already carries a value, which is kept as it is (the host app's choice, or an earlier pin; this is what makes the call idempotent). One debug-tier log line names which root class is in effect, never the path. |
| [trimOnMemoryPressure](trimOnMemoryPressure.md) | [android]<br>@[JvmStatic](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-static/index.html)<br>fun [trimOnMemoryPressure](trimOnMemoryPressure.md)(context: Context)<br>Give the runtime's idle device memory back when the platform asks for memory. Registers ONE listener on the application for the system's memory-pressure signals; when the process reaches the running-low level or any level above it (running-critical, the UI hidden, the app in the background), the runtime releases the memory it keeps cached for reuse on every device it has loaded, so a low-memory phone keeps the app alive instead of killing it. Memory still in use is never touched, and below running-low nothing is released. A second call is a no-op. Call it after [load](load.md). |