Skip to main content

Introduction

The SPREEAI Android SDK enables users to experiment with outfits virtually by utilizing AI to superimpose garments onto uploaded pictures, thereby creating a visual representation of the outfit on the individual.

Technical Requirements

  • minSdk 21 (Android 5.0 Lollipop)
  • compileSdk 35 (Android 15 Vanilla Ice Cream)
  • Gradle 8.x
  • Kotlin 2.1.x
  • Compose UI 1.7.x

Prerequisites

Provided by SPREEAI

  • SPREEAI partner ID
  • Skin IDS
  • Branch.io
    • Live Key
    • Test Key
    • URI Scheme
    • Link Domains

Supply to SPREEAI

  • Application ID
  • SHA-1 certificate fingerprint
  • SHA-256 certificate fingerprint

Installation

Add the dependency to your build.gradle file:

dependencies {
implementation("com.spreeai:tryon:1.0.0")
}

Proguard

The proguard rules are already bundled into the library which can be interpreted by R8 automatically.

Configuration

There are 2 ways to configure the SDK. The configuration inside your Application will override anything you put inside AndroidManifest.xml.

1. Inside AndroidManifest.xml

<meta-data
android:name="com.spreeai.android.partner_id"
android:value="YOUR_SPREEAI_PARTNER_ID" />
<meta-data
android:name="com.spreeai.android.partner_name"
android:value="YOUR_SPREEAI_PARTNER_NAME" />
<meta-data
android:name="com.spreeai.android.theme.primary_color"
android:value="@color/primary" />
<meta-data
android:name="com.spreeai.android.theme.font"
android:value="@font/my_font" />
<meta-data
android:name="com.spreeai.android.environment"
android:value="prod" />

2. Inside your Application

override fun onCreate() {
SpreeAI.init {
partnerId = YOUR_SPREEAI_PARTNER_ID
partnerName = YOUR_SPREEAI_PARTNER_NAME
theme = SpreeAI.Theme(
primaryColor = ContextCompat.getColor(context, R.color.primary),
typeface = ResourcesCompat.getFont(context, R.font.my_font)
)
environment = Environment.Prod
}
}

Parameter Details

ParameterTypeDescriptionRequiredDefault
partnerIdStringYour unique partner identifier provided by SPREEAIYes
partnerNameStringYour brand name to be shown inside the SDKNonull
themeSpreeAI.ThemeCustomise your users experience in the SDKNonull
environmentEnvironmentPossible values:NoProd

Usage

There are 3 ways to use the SDK. Choose the method best suited to your situation.

1. Using Activity or Fragment

val tryOn = SpreeAITryOn(this) { result ->
when (result) {
is Result.Completed -> // Additional actions after the try-on is completed
is Result.Canceled -> // Additional actions after the try-on was canceled
is Result.Redirect -> // Redirect the user within the app to a specific garment if necessary
is Result.AddToCart -> // Add to cart within the app with a specific garment and size
}
}

fun onTryOnClicked() {
tryOn.startTryOnFlow(garmentId = "your garment id")
}

2. Using Compose

val tryOn = rememberSpreeAITryOn { result ->
when (result) {
is Result.Completed -> // Additional actions after the try-on is completed
is Result.Canceled -> // Additional actions after the try-on was canceled
is Result.Redirect -> // Redirect the user within the app to a specific garment if necessary
is Result.AddToCart -> // Add to cart within the app with a specific garment and size
}
}

Button(
onClick = {
tryOn.startTryOnFlow(garmentId = "your garment id")
}
) {
Text("Try On")
}

If you are in a situation not previously covered, the SDK provides a SpreeAITryOnContract class that allows you more flexible control. This is use internally by the other methods.

See how to use it: Get a result from an activity

Deep Linking

Branch.io is used for handling deep links and deferred deep links for specific garment. The project information will be provided by SPREEAI.

The SpreeAITryOn SDK provides a DeepLink object that acts as a wrapper around Branch SDK.

You will need to have the following information:

  • Live Key
  • Test Key
  • URI Scheme
  • Link Subdomain

Add both your live and test keys

Inside AndroidManifest.xml

<meta-data
android:name="io.branch.sdk.BranchKey"
android:value="YOUR_LIVE_KEY" />
<meta-data
android:name="io.branch.sdk.BranchKey.test"
android:value="YOUR_TEST_KEY" />

<!-- Optional - Use Test Mode (defaults to false) -->
<meta-data
android:name="io.branch.sdk.TestMode"
android:value="false" />

Add your URI scheme, subdomain and launcher activity full name

Inside build.gradle

manifestPlaceholders += mapOf(
"launcherActivity" to "YOUR_LAUNCHER_ACTIVITY_FULL_NAME",
"branchUriScheme" to "YOUR_URI_SCHEME",
"branchSubdomain" to "YOUR_LINK_SUBDOMAIN"
)

Inside Application

override fun onCreate() {
DeepLink.init(this)
}

Inside your launcher Activity

override fun onStart() {
DeepLink.initSession(this) { deepLinkData ->
onDeepLink(deepLinkData)
}
}

override fun onNewIntent(intent: Intent) {
DeepLink.reInitSession(this, intent) { deepLinkData ->
onDeepLink(deepLinkData)
}
}

fun onDeepLink(deepLinkData: DeepLink.Data) {
// Navigate to your garment detail screen

// This object must be used to start the try on flow
tryOn.startTryOnFlow(deepLinkData)
}

NOTE: See Branch Android SDK to have more information about Branch integration and features.

Sentry

Sentry is used for error reporting and performance monitoring. If you want to use Sentry, you might need to update auto-init to true in the Android Manifest file.

Frequently Asked Questions (FAQ)

How do I get a SPREEAI partner account?

You can sign up for a partner account by visiting SPREEAI Partner Signup.

What are the supported languages?

The SDK currently supports English (en), Spanish (es), Italian (it) and French (fr).