Installing the Mobile SDK for Android

At a glance

Use the Mailchimp SDK to manage contacts in a Mailchimp audience from your Android app.

  • Add new users straight to an audience

  • Update contacts based on user action

  • Add relevant tags to contacts

  • Set or update merge fields

This article walks you through the process of installing and configuring the Mailchimp SDK for Android.

What you’ll need

  • Android API Level 21 (5.0) and above

Retrieve the SDK Key

Before you begin, you'll need to obtain a Mobile SDK key so you can access and configure the SDK.

  1. Go to the Your API Keys section of your Mailchimp account and click on Your Mobile SDK Client

  2. If a key exists, copy it to your clipboard and skip to “Initialize the SDK”

  3. If you need to create a new key, click Create A Key

  4. Select an audience, and then name your key descriptively

  5. Click Create Key

Add the Mailchimp SDK to your project

First, add https://jitpack.io to your list of maven repositories if it's not already present.

Here is a list of Gradle repositories that contains jitpack.

repositories { mavenCentral() maven { url 'https://jitpack.io' } // <-- New repository }

Next, add the Mailchimp SDK to your list of dependencies.

Here is a Gradle example.

implementation 'com.github.mailchimp:Mailchimp-SDK-Android:0.1.0'

Initialize the SDK

The first step is to create the configuration object and define these fields.

Required

  • SDK Key: The SDK Key grants access to an audience.

Optional

  • Debug Mode: Debug Mode enables additional debug only functionality such as extra logging. This is off by default.

  • Auto Tagging: Auto Tagging automatically tags contacts with information, such as Device Type and Platform. This is on by default.

Here’s an example configuration.

val sdkKey = "12345678901234567890123456789012-us12" //Example SDK Key val isDebugBuild = BuildConfig.DEBUG val configuration = MailchimpSdkConfiguration.Builder(context, sdkKey) .isDebugModeEnabled(isDebugBuild) .isAutoTaggingEnabled(true) .build()

After it’s set, call the initialize method. Here’s an example.

val mailchimpSdk = Mailchimp.initialize(configuration)

This initializes the SDK and returns the new shared instance. We recommend that you initialize on app start.

You can also access the Shared Instance by calling Mailchimp.sharedInstance().

Note: The Mobile SDK key does not provide access to the Mailchimp Marketing API but should still be considered private and kept safe.

Next steps

Congratulations! You've successfully installed the Mobile SDK for Android. To learn how to use it, see Using the Mobile SDK for Android.