# Troubleshooting

> Canonical URL: https://docs.mountaya.com/en/sdks/kotlin/troubleshooting/
> Last updated: 2026-11-27
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

The problems developers hit first with the Kotlin SDK, and how to fix each one.

The problems developers hit first, each with its fix.

## `Credential.Secret` does not resolve in my app

The secret key is declared on the JVM alone, so an Android or iOS build cannot name it. Keep it on your server, and build the app's client with `Credential.Publishable` and a session token your server mints. See [authentication in the SDK](https://docs.mountaya.com/en/sdks/kotlin/authentication.md#secret-key).

On a JVM server, import the factory that builds it:

```kotlin
import com.mountaya.client.Credential
import com.mountaya.client.Mountaya
import com.mountaya.client.invoke

val server = Mountaya(Credential.Secret(System.getenv("MOUNTAYA_SECRET_KEY").orEmpty()))
server.close()
```

## `mountaya.admin` does not resolve

The admin operations come with `mountaya-admin` and one import. Add the module to the server's build, then:

```kotlin
import com.mountaya.admin.admin
import com.mountaya.client.Mountaya

suspend fun organizationName(mountaya: Mountaya, organizationId: String): String =
    mountaya.admin.organizations.getOrganization(organizationId).data.name
```

## `MapView` does not resolve

`MapView` and every composable of `mountaya-elements` are Android only. Call them from `androidMain`, or from an Android app module. On iOS and the JVM, `MapEngine` holds the map's state for views of your own.

## The client throws `ConfigurationException` as it is built

The key is empty, has the wrong prefix, or holds a character no HTTP header carries, such as the `…` of a placeholder. Check that `BuildConfig.MOUNTAYA_PUBLISHABLE_KEY` holds the key your `.env` names, and rebuild after changing the file.

- The client checks a credential where it is built and before each request, and refuses with `ConfigurationException` before anything leaves the device: an empty key, a wrong prefix, a secret key in a publishable key's place, a character outside printable ASCII. Its message never quotes the value.
- A `BuildConfig` field is written at build time: Gradle reads `.env` (or the environment) when it configures the build, so a changed key needs a new build, and a key missing from both writes an empty field.

## Search or a Data API call answers 401

The Data API answers a publishable key only beside a live session token, and a token given as a value expires within minutes. Give the client a `SessionTokenEngine` whose `mint` asks your server, as [keep the token fresh](https://docs.mountaya.com/en/sdks/kotlin/authentication.md#rotate) shows.

- An expired or unknown token answers `401`, an `AuthenticationException`. Without any token, the client refuses a call that requires one (every Data API call, search included) with `ConfigurationException` before sending. Where an engine's last mint failed, the exception's `cause` is that failure: check your server's answer.
- `SearchControl` shows a failed line per branch in that case, and hands each failure to `onError`.

## The map stays empty

The API refused the map's own requests: the key lacks the `tiles` scope, or the agreement does not cover the Tile API. Watch `map.state.value.isAccessRequired`, or collect `map.events()` and log each `MapEvent.AccessRefused` with its status and address. See [hear what the map refuses](https://docs.mountaya.com/en/sdks/kotlin/map.md#errors).

- An Android app also needs `android.permission.INTERNET` in its manifest; without it every request of MapLibre and the client fails with no answer (`MapEvent.Failure`, `ConnectionException`).
- A published itinerary needs the `publishing` scope beside `tiles`.

## A write answers `401`

The token was minted for another use, or is minted without `user_id`. Mint it on your server with `user_id` set and `surface = RestSchema.SessionSurface.StudioEmbedded`, under a key carrying the `studio-embedded` scope. See [act as a member](https://docs.mountaya.com/en/sdks/kotlin/authentication.md#act-as-member).

## A call answers `402`

Your organization's agreement does not cover the call, or a payment is due. Code cannot fix it: show the `BillingException`'s message, which names the fact and where it is resolved, and never retry.

## A webhook delivery never verifies

`constructWebhookEvent` needs the body exactly as it arrived. Read it as bytes before any JSON parser touches it, and pass the endpoint's own secret, `whsk_` included. See [verify a delivery](https://docs.mountaya.com/en/sdks/kotlin/webhooks.md#verify).

- `WebhookSignatureException.reason` says which: `MissingHeader` (no `Mountaya-Signature`), `MalformedHeader`, `Signature` (wrong secret or changed body) or `Timestamp` (your clock is more than 300 seconds from the signature's, or you replayed an old delivery).
- A server framework that parses JSON first hands you other bytes: take the raw body (`ByteArray`) from the request.

## Navigation reads no position

`DeviceLocationSource` reads only under the full location permission. Declare `ACCESS_FINE_LOCATION` beside `ACCESS_COARSE_LOCATION`, ask for it in your own flow, then call `recheckPermission()` from the result.

- Under the approximate permission alone, the source reads nothing and `standing` states `LocationAccuracy.Reduced`; a map's `locate()` is refused as `denied`.
- Hand the source an `onError` to hear each failure: `NoProvider`, `PermissionRevoked`, `ProviderDisabled` (location turned off), `PlatformFailed`, `BackgroundUndeclared`.

## Navigation says nothing

The device's speech engine did not start, or your sentence function answered `null` for that instruction. Call `voice.prepare()` up front, and hand the voice an `onError`: it hears `SpeechException.Kind.EngineUnavailable` where the device has no usable engine.

## The build refuses `compileSdk` or `minSdk`

The modules need `compileSdk 37` or higher and `minSdk 24` or higher, Kotlin 2.4 and Java 17. Raise the app's build to those floors. See [requirements](https://docs.mountaya.com/en/sdks/kotlin.md#requirements).

## Next steps

- [Errors and retries](https://docs.mountaya.com/en/sdks/kotlin/errors.md): The exception ladder and what each class means.
- [Install and set up](https://docs.mountaya.com/en/sdks/kotlin/install.md): The modules, the floors and your key.
