Quickstart Guide#
This is a developers' guide for setting up Storyteller for native Android apps. This guide will cover the basic technical steps for initializing the Storyteller SDK, authenticating a user, and adding a StorytellerStoriesRowView to your app.
Resources#
Showcase examples#
- Compose — SDK init in
ShowcaseApp - Compose —
Storyteller.initializeinStorytellerServiceImpl - XML — SDK init in
ShowcaseApp - XML —
Storyteller.initializeinStorytellerServiceImpl
How to Add the SDK to Your Project#
Before you can add the Android SDK to your app, you will need to obtain an API Key. This is a secret key used to authenticate the SDK in your app. Throughout this document it will be marked as [APIKEY].
SDK Dependencies#
Currently the Android SDK contains the following dependencies.
R8 / ProGuard#
If your app uses R8, the rules are added automatically.
SDK Installation#
The Android SDK can be included in your project using Gradle. It is recommended to use Android Studio. If you are having problems with configuring your build, check out the Android Studio guide or Gradle guides.
- Add the maven repository for the SDK in the Project
build.gradlefile (MyAwesomeApp/build.gradle), under theallprojectssection
Note: make sure it is added to
allprojects, and notbuildscript
...
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://storyteller.mycloudrepo.io/public/repositories/storyteller-sdk'
}
}
}
- Modify the app Module
build.gradlefile (MyAwesomeApp/app/build.gradle)
...
dependencies {
def storyteller_version = "11.2.0"
implementation(group: "Storyteller", name: "sdk", version: "$storyteller_version")
}
-
Sync your project with Gradle files
-
Android Studio

SDK Initialization#
Before using the Android SDK in your app, you need to initialize it with an API key.
Adding an API Key#
Use the initialize(apiKey: String, userInput: StorytellerUserInput? = null, eventTrackingOptions: StorytellerEventTrackingOptions = StorytellerEventTrackingOptions(), onSuccess: () -> Unit = {}, onFailure: (Error) -> Unit = {}) public method to manually initialize the SDK at runtime. This will authenticate the SDK on the Storyteller API and configure it with the corresponding settings.
apiKey: (Required) the API key you wish to initialize the SDK withuserInput: details of the user to be authenticated (this should be a unique user ID. If this is not set, the default value is used)eventTrackingOptions: privacy and tracking configuration options (defaults to all tracking enabled)onSuccess: callback for successful completiononFailure: callback for failed completion with error
Usage:
Storyteller.initialize(
apiKey = "[APIKEY]",
userInput = StorytellerUserInput("unique-user-id"),
eventTrackingOptions = StorytellerEventTrackingOptions(
enablePersonalization = true,
enableStorytellerTracking = true
// ... other options
),
onSuccess = {
// onSuccess action
},
onFailure = { error ->
// onFailure action
}
)
Initialization errors:
InitializationError: when the context isnullInvalidAPIKeyError: when an invalid API key is usedNetworkError: when the call to load the settings for the SDK fails (i.e. a non-success HTTP status code is returned)NetworkTimeoutError: when the call to load the settings for the SDK times outJSONParseError: when a malformed settings response is received from the server
Note: Please be aware that this method is asynchronous
Authenticate a User#
For more information about Users and External IDs, please see Working with Users
Adding a StorytellerStoriesRow Composable#
- At first we will need a nesting composable. You can use any composable layout you want:
Box,Column,LazyColumn, etc.
@Composable
fun MainScreen() {
Box() {
// ...
}
}
- Storyteller Composables Now it's time to add the Storyteller Composables to your app. The Storyteller Composables are the building blocks of the Storyteller SDK.
StorytellerStoriesRow(
modifier = Modifier,
dataModel = StorytellerStoriesDataModel(categories = emptyList()), // data model with the configuration for your Composables. We will describe how to use StorytellerDataModel below.
delegate = listViewDelegate, // delegate for the Composables. We will describe how to use StorytellerListViewDelegate below.
state = rememberStorytellerRowState() // state for the Composables. We will describe how to use StorytellerRowState below.
)
XML Views (Legacy)#
Prefered way to add Storyteller Lists is to use Composables. Storyteller still supports XML/Views and the guide can be found in the StorytellerListViews documentation.