# Migrating Android API Wrapper from version 3.x. to 4.x

This guide helps developers transition from version 3.x to 4.x with clear examples and detailed references.

Topics: Android, Server and Scripting

Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)

Source: https://developer.what3words.com/tutorial/migrating-android-api-wrapper-from-version-3-x-to-4-x

Updated: 2026-11-30

In version 4.0, the Android API Wrapper library changed significantly. This guide will help you gradually adapt your existing code to the new wrapper.

**Note**:

- For users still on version 3.x, see the [legacy Android tutorial](https://developer.what3words.com/tutorial/legacy-android).
- For users on version 4.x, see the [latest Android tutorial](https://developer.what3words.com/tutorial/android).

## 1. Introduction to the Core Library

The core library establishes essential models and interfaces that maintain consistency across various other libraries. Significant changes have been made by substituting existing models with those from the core library. It is imperative to update your code accordingly to utilise these new models.

**Android v4 Tutorial**: For a comprehensive guide to the latest version 4.x, see the [Android tutorial](https://developer.what3words.com/tutorial/android).

### Model Replacements

| Android v3 models | Android v4 models |
| --- | --- |
| com.what3words.javawrapper.response.SuggestionWithCoordinates | com.what3words.core.types.domain.W3WSuggestion |
| com.what3words.javawrapper.request.AutosuggestOptions | com.what3words.core.types.options.W3WAutosuggestOptions |
| com.what3words.javawrapper.response.Coordinates | com.what3words.core.types.geometry.W3WCoordinates |
| com.what3words.javawrapper.response.Square | com.what3words.core.types.geometry.W3WRectangle |
| com.what3words.core.domain.language.W3WLanguage | com.what3words.core.types.language.W3WLanguage |
| com.what3words.javawrapper.request.BoundingBox | com.what3words.core.types.geometry.W3WRectangle |
| com.what3words.androidwrapper.voice.Microphone | com.what3words.core.datasource.voice.audiostream.W3WMicrophone |

## 2. Transition to W3WApiTextDataSource and W3WApiVoiceDataSource

The Android API Wrapper version 3 What3WordsV3 has been restructured into two distinct classes:

- **W3WApiTextDataSource**: Handles text-based tasks like address searching and conversions.
- **W3WApiVoiceDataSource**: Specialises in voice-based address suggestions.

For more information on using version 4.x, see the [latest Android tutorial](https://developer.what3words.com/tutorial/android).

## 3. Method Changes List

### convertToCoordinates

Converts a what3words address to coordinates.

**Android v3**

```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.convertToCoordinates(words).execute()
```

**Parameters**:

- `words`: String (the what3words address to convert)

**Return**: ConvertToCoordinates (coordinates corresponding to the what3words address)

**Android v4**

```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY) 
val result = textDataSource.convertToCoordinates(words) // Must run on background thread
```

**Parameters**:

- `words`: String (the what3words address to convert)

**Return**: W3WResult<W3WAddress> (result containing the coordinates)

For more details and instructions, see [Convert to Coordinates Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#converttocoordinates-example).

### convertTo3wa

Converts coordinates to a what3words address.

**Android v3**

```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.convertTo3wa(coordinates).execute()
```

**Parameters**:

- `coordinates`: Coordinates (latitude and longitude to convert)

**Return**: ConvertTo3WA (the corresponding what3words address)

**Android v4**

```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY) 
val result = textDataSource.convertTo3wa(coordinates, language) // Must run on background thread
```

**Parameters**:

- `coordinates`: W3WCoordinates (latitude and longitude to convert)
- `language`: W3WLanguage (the language for the what3words address)

**Return**: W3WResult<W3WAddress> (result containing the what3words address)

For more details and instructions, see [Convert to what3words Address Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#converttocoordinates-example).

### AutoSuggest

Provides address suggestions based on a partial or full what3words address.

**Android v3**

```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.autosuggest(word).execute()
```

**Parameters**:

- `word`: String (the partial or full what3words address to get suggestions for)

**Return**: Autosuggest (list of suggested addresses)

**Android v4**

```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY) 
val result = textDataSource.autosuggest(word, options) // Must run on background thread
```

**Parameters**:

- `word`: String (the partial or full what3words address to get suggestions for)
- `options`: W3WAutosuggestOptions? (optional parameters to refine suggestions)

**Return**: W3WResult<List<W3WSuggestion>> (result containing the list of suggestions)

For more details and instructions, see [Autosuggest Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#autosuggest-example).

### availableLanguages

Fetches the list of available languages for what3words addresses.

**Android v3**

```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.availableLanguages().execute()
```

**Return**: AvailableLanguages (set of supported languages)

**Android v4**

```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY) 
val result = textDataSource.availableLanguages() // Must run on background thread
```

**Return**: W3WResult<Set<W3WProprietaryLanguage>> (result containing the set of supported languages)

For more details and instructions, see [Get Available Languages Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#availablelanguages-example).

### gridSection

Retrieves a section of the what3words address grid for a specified bounding box.

**Android v3**

```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.gridSection(boudingBox).execute()
```

**Parameters**:

- `boundingBox`: BoundingBox (the area to get the grid section for)

**Return**: GridSection (section of the grid)

**Android v4**

```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY) 
val result = textDataSource.gridSection(boundingBox) // Must run on background thread
```

- **Parameters**:
    - `boundingBox`: W3WRectangle (the area to get the grid section for)
- **Return**: W3WResult<W3WGridSection> (result containing the section of the grid)

For more details and instructions, see [Grid Section Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#gridsection-example).

### Voice AutoSuggest

Provides address suggestions based on voice input.

**Android v3**

```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.autosuggest(microphone, voiceLanguage)
    .onSuggstions { suggestions ->
        // Handle the suggestions
    }
    .onError { error ->
        // Handle the error
    }
```

**Parameters**:

- `microphone`: Microphone (the audio input device)
- `voiceLanguage`: String (the language for voice recognition)

**Return**:

- `suggestions`: List<Suggestion> (list of suggested addresses)
- `error`: APIResponse.What3WordsError (error information)

**Android v4**

```kotlin
val voiceDataSource = W3WApiVoiceDataSource.create(API_KEY) 
val result = voiceDataSource.autosuggest(
        audioStream,
        voiceLanguage,
        options,
        onSpeechDetected,
    ) { result ->
        // Handle result
    }
```

**Parameters**:

- `input`: W3WAudioStream (the audio input stream)
- `voiceLanguage`: W3WLanguage (the language for voice recognition)
- `options`: W3WAutosuggestOptions? (optional parameters to refine suggestions)
- `onSpeechDetected`: ((String) -> Unit)? (callback for speech detection)

**Return**:

- `result`: W3WResult<List<W3WSuggestion>> (result containing the list of suggestions)

For more details and instructions, see [Voice Autosuggest Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#w3wapivoicedatasource).

## 4. AutosuggestHelper

In the previous version, AutosuggestHelper relied on the Android API Wrapper v3 (What3WordsV3). Now, it has transitioned to using `W3WApiTextDataSource`.

**Android v3**

```kotlin
val what3words = What3WordsV3("YOUR_API_KEY_HERE", this)
val autosuggestHelper = AutosuggestHelper(what3words)
```

**Android v4**

```kotlin
val dataSource = W3WApiTextDataSource.create(context, "YOUR_API_KEY_HERE")
val autosuggestHelper = AutosuggestHelper(dataSource)
```

For more details and instructions, see [AutoSuggestHelper](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#using-autosuggesthelper-class).
