# Android reference (TryYourSize for Kotlin)

> The native Size guide button (Compose and Views), the shopper's recommended size, and the TryYourSize window.

Source: https://docs.tryyoursize.com/reference/android/

*SDK* · `com.tryyoursize:tryyoursize-android` · v0.1.0

minSdk 24, Jetpack Compose and Views. The window needs an androidx `ComponentActivity` (for example `AppCompatActivity`). Register your app for the key in Studio as `android-app://<package>` (test mode today; live mode for apps is coming soon).

## Install

**Gradle (Kotlin)**

```kotlin
dependencies { implementation("com.tryyoursize:tryyoursize-android:0.1.0") }
```

## Initialize

**Kotlin**

```kotlin
val tys = TryYourSize(context, "pk_test_…") // a secret key throws
```

**Swift**

```swift

let tys = try TryYourSize(publishableKey: "pk_test_…") // a secret key throws
```

Error codes: [Mobile SDK errors](https://docs.tryyoursize.com/mobile/errors.md).

## Client

| | |
|---|---|
| [`constructor`](https://docs.tryyoursize.com/reference/android/constructor.md) | Creates the client for your publishable key. |
| [`Configuration`](https://docs.tryyoursize.com/reference/android/configuration.md) | TryYourSize.Configuration |
| [`recommendation()`](https://docs.tryyoursize.com/reference/android/recommendation.md) | The shopper's recommended size for a product, in your size labels. |
| [`getRecommendation()`](https://docs.tryyoursize.com/reference/android/get-recommendation.md) | The same, with a callback (Java). |
| [`onRecommendation()`](https://docs.tryyoursize.com/reference/android/on-recommendation.md) | Calls handler now (once known) and on every change: signing in, a new body, a simulation finishing. |
| [`on (events)`](https://docs.tryyoursize.com/reference/android/on.md) | Window events: Ready, Open, Close, Size, LoadError. |
| [`present()`](https://docs.tryyoursize.com/reference/android/present.md) | Opens the measuring / try-on window for a product, full screen over activity. |
| [`appearance`](https://docs.tryyoursize.com/reference/android/appearance-property.md) | Live restyle (e.g. |
| [`appOrigin`](https://docs.tryyoursize.com/reference/android/app-origin.md) | android-app://<package>: what the store registers as an allowed origin. |

## Size guide button

| | |
|---|---|
| [`SizeGuide`](https://docs.tryyoursize.com/reference/android/size-guide.md) | The "Size guide" button: "Size guide" → "Calculating your size…" → "Your size: M". |
| [`SizeGuideView`](https://docs.tryyoursize.com/reference/android/size-guide-view.md) | The same button as an Android View: set client and product. |

## Types

| | |
|---|---|
| [`Recommendation`](https://docs.tryyoursize.com/reference/android/recommendation-type.md) | The shopper's recommended size for one product, in the store's own size labels. |
| [`Appearance`](https://docs.tryyoursize.com/reference/android/appearance.md) | Colours (ARGB ints), font and corner radius for the button and the window. |
| [`TryYourSizeException`](https://docs.tryyoursize.com/reference/android/errors.md) | Every error the SDK raises: a stable code, a message and a doc link (like the web SDK). |
