Skip to main content

Android SDK Build

Offer Scan & Go to your customers in your own Android App with this SDK. Our mobile SDK supports the entire range of Snabble base functionality including scanning, product lists, promotions, payment and shops.
The SDK covers the whole communication with the Snabble Cloud-Platform and provides you with UI elements for your app that are easy to use and customize, so that you simplify the integration of Scan & Go into your app significantly.
For details about integrating with the Snabble Cloud-Platform, please see the Platform Documentation on GitHub.

Requirements

  • minSdkVersion = 21
  • compileSdkVersion = 31
  • Java 8 with desugaring enabled
  • AndroidX and a Material 3 theme for UI components

Installation

The Snabble Gradle Plugin is for the simplest setup of the Snabble Android SDK. With this plugin you can reduce the SDK integration to 5 lines in your codebase. You can also download the manifest in your CI to bundle the latest metadata with your app so that your user it can use your app with all required meta data.

Add plugin

Using the plugins DSL:

plugins {
id 'com.android.application'
id 'io.snabble.setup' version '{latestVersion}' // add this line
}
Hint: Latest version is embedded in image

Using the plugin

The absolut minimum is to add those two lines to make the SDK already working:

snabble.production.appId = 'your-app-id'
snabble.production.secret = 'your-app-secret'

When you use to add the dependency:

dependencies {
// your other dependencies
implementation 'io.snabble.sdk:ui:{latestVersion}' // add this line
}
Hint: Latest version is embedded in image

For further usage information check the Gradle-Plugin documentation.

Alternative installation

Add the Snabble Repository to your gradle Repositories:

repositories {
maven {
url 'https://raw.githubusercontent.com/snabble/maven-repository/releases'
}
}

Then add the library to your dependencies.

dependencies {
// core library
implementation 'io.snabble.sdk:core:{latestVersion}'

// user interface library
implementation 'io.snabble.sdk:ui:{latestVersion}'
}

You can initialize the SDK by specifying metadata in the AndroidManifest.xml

<meta-data android:name="snabble_app_id" android:value="YOUR_APP_ID" />
<meta-data android:name="snabble_secret" android:value="YOUR_SECRET" />

Manual initialization

You also can initialize the SDK programmatically by specifying in the AndroidManifest.xml:

<meta-data android:name="snabble_auto_initialization_disabled" android:value="true" />

And then initialize the SDK via code.

val config = Config(
appId = YOUR_APP_ID,
secret = YOUR_SECRET,
)
Snabble.setup(application, config)

To observe the current initialization state of the SDK use:

Snabble.initializationState.observe(this) {
when(it) {
InitializationState.INITIALIZING -> {}
InitializationState.INITIALIZED -> {
val projects = Snabble.projects // access to projects
}
InitializationState.ERROR -> {
// error detailing why the initialization failed
val error = Snabble.error
// you can call setup again without arguments to retry the initialization
// e.g. on network failure
Snabble.setup()
}
}
}

Light mode themes

If using a theme that is explicitly only light mode (and not a DayNight theme) you need to set

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

or else some resources may get grabbed from the "-night" folders when the device is set to night mode

Sample Apps

We have currently 3 sample apps which you can check to integrate the SDK into your own app:

If you have still open questions feel free to open an issue on the SDK or contact our support team.