# Android

## Migration Guide (Android 1.29.x → 2.0.x) <a href="#toc_0" id="toc_0"></a>

Sections are ordered for a typical integration.

{% stepper %}
{% step %}

#### Platform

`minSdkVersion` 29 (Android 10) or higher.
{% endstep %}

{% step %}

#### Initialization

Remove environment and region from SDK initialization.

Also remove any code that depends on environment or region from the SDK.

```kotlin
// Delete from the builder chain
.setSdkApiConfigEnvironment(...)
.setSdkApiConfigRegion(...)
```

{% endstep %}

{% step %}

#### Removed APIs

```
// Delete
ImsSdkManager.updateSdkConfig(context)

// Delete from the config builder
SdkConfigBuilder(...).apiKey(...)
```

{% endstep %}

{% step %}

#### Identity - drop apiKey

`apiKey` is no longer part of the IMS public API. Stop persisting or accessing it through `Identity`.

```kotlin
// Before
Identity(apiKey = apiKey, externalReferenceID = userId)
```

```kotlin
// After
Identity(externalReferenceID = userId)
```

{% endstep %}

{% step %}

#### Logging in a user

Call `setIdentity` once on login success — not on every `onResume` unless that genuinely represents a new login. If you observed `currentIdentity` via `StateFlow`, drop that pattern; the SDK no longer exposes it.

On `isFailure`, the user is not signed in to the SDK. Portal, trip detection, or other IMS APIs will not be available until `setIdentity` succeeds again.

```kotlin
// Before
val flow = ImsSdkManager.setIdentity(context, identityOrNull)
flow.collect { result ->
    when {
        result.isSuccess -> { }
        result.isFailure -> { }
    }
}
```

```kotlin
// After
lifecycleScope.launch {
    val result = ImsSdkManager.setIdentity(context, identity)
    when {
        result.isSuccess -> { }
        result.isFailure -> { }
    }
}
```

{% endstep %}

{% step %}

#### Logging out a user

`clearIdentity` is required on every logout in 2.0.x, and replaces the prior `setIdentity(context, null)` pattern.

The SDK persists identity across launches, so skipping this call leaves the previous user's identity in place — trip detection and `Portal` calls continue under that user until you call it.

Call it once per logout. It is a `suspend` function — call from a coroutine. Any SDK API call made after invoking this method will fail.

```kotlin
// Before
ImsSdkManager.setIdentity(context, null)
```

```kotlin
// After
lifecycleScope.launch {
    ImsSdkManager.clearIdentity(context)
}
```

{% endstep %}

{% step %}

#### Disabling Trip Detection

The `deleteTripFiles` flag is removed. For full logout and clearing local SDK user state, use `ImsSdkManager.clearIdentity` (see [#logout-clearidentity](#logout-clearidentity "mention")). Use `disableTripManager` only to stop detection.

```kotlin
// Before
ImsTripManager.disableTripManager(context, deleteTripFiles = true)
```

```kotlin
// After
ImsTripManager.disableTripManager(context)
```

{% endstep %}

{% step %}

#### AppMisuseManager

AppMisuse enable/disable handling is now managed internally by the SDK.

No replacement is needed. Other usage of `AppMisuseManager`, if any, are unaffected.

The two public toggles are gone:

```kotlin
// Delete
AppMisuseManager.enableAppMisuse(...)
AppMisuseManager.disableAppMisuse(...)
```

{% endstep %}
{% endstepper %}

***

## See also — new in 2.0.x (no migration required)

These additions are opt-in and require no changes to ship a working 2.0.x upgrade. Adopt them when you're ready:

* Crash Detection events — listen for crash events and submit user feedback via `ImsTripManager.getCrashClient()`. See [Crash Detection events](https://sdk.ims.tech/~/changes/197/crash-detection-events).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk.ims.tech/migration-guides/migrating-from-1.29.x-to-2.0.x/android.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
