Import the App SDK

Prev Next

Flowchart illustrating steps for Usercentrics SDK implementation and consent management process.

The first step on the technical implementation side is to import the necessary SDK module(s) into your project.

Before you begin, it’s important to learn the following detail about the App SDK architecture: it includes the following two components:

  • UsercentricsCore: Contains all core functionality to collect, document and manage consent. If you want to build your own banner UI, that’s the only module you need.

  • UsercentricsUI: This component builds on the top of UsercentricsCore to provide a pre-built consent banner solution. Use it for a quick but still customizable solution. If you want to use this component, you must import UsercentricsCore as well.

The following sections show how to import the necessary modules under the different environments: iOS, Android, Flutter, React Native, Unity.

iOS

Prerequisite

iOS 11 or higher

CocoaPods

  1. Install CocoaPods and follow the CocoaPods documentation to set up your project.

  2. On your Podfile, add the following line to include both UsercentricsCore and UsercentricsUI:

    platform :ios, '11.0'
    use_frameworks!  
    pod 'UsercentricsUI'


    Alternatively, add the following to include only UsercentricsCore:

    platform :ios, '11.0'
    use_frameworks!  
    pod 'Usercentrics'
  3. On the root directory of your project, run the following command to install the pod:

    pod install
  4. Open your .xcworkspace file.

🚀 You are now ready to start integrating Usercentrics.

Swift Package Manager (SPM)

From Xcode 11 and above, you can use Swift Package Manager to install the SDK.

  1. On Xcode, select File - Swift Packages - Add Package Dependency.

  2. Enter the package repository URLs.

    1. For Usercentrics UI: https://bitbucket.org/usercentricscode/usercentrics-spm-ui

    2. For UsercentricsCore: https://bitbucket.org/usercentricscode/usercentrics-spm-sdk

  3. Select the version you would like to use. We recommend sticking to "Up to Next Major" with the latest release as minor version.

🚀 You are now ready to start integrating Usercentrics.

Manually

Download and unzip the latest version of our SDKs:

  1. UsercentricsCore

  2. UsercentricsUI. Download the zip file containing 'Manual-Linking' in its name.

  3. Drag and drop .xcframework files to your Xcode project.

🚀 You are now ready to start integrating Usercentrics.

Android

Prerequisite

Android 7.0 (API 24) or higher

Android minimum SDK version

Support for versions lower than Android 5.0 (API Level 20) is planned to be removed in releases starting from April/24

Gradle

  1. If not present, add Maven Central repository URL to your top-level build.gradle file:

    allprojects {
        repositories {
            mavenCentral()
        }
    }
  2. Add the dependency to your app's build.gradle to include both UsercentricsCore and Usercentrics UI:

    dependencies {
        implementation "com.usercentrics.sdk:usercentrics-ui"
    }

    Alternatively, add the following to include only UsercentricsCore:

    dependencies {
        implementation "com.usercentrics.sdk:usercentrics"
    }

🚀 You are now ready to start integrating Usercentrics.

Manually

  1. Download and the latest version of our SDKs: Usercentrics Core and Usercentrics UI.

  2. Check the POM file is available in both links above. They may contain other libraries to be downloaded, download them if they are not present already in your environment.,

  3. If the dependencies are handled manually, move all .aar and .jar files to your project, if not, upload them to your Nexus solution.

🚀 You are now ready to start integrating Usercentrics.

Flutter

Prerequisites

  • Android 7.0 (API 24) or higher with Kotlin 1.9 or higher

  • iOS 11 or higher

  • Dart 2.12 or higher

  • Flutter 1.20 or higher

Android minimum SDK version

Support for versions lower than Android 5.0 (API Level 20) is planned to be removed in releases starting from April/24

Android with Kotlin version < 1.7

If you have an incompatible Kotlin version, you may see the following error when you run app on Android:

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors

To solve this error, increase the version that is usually in the android/build.gradle file. Use a recent stable Kotlin version, for example: 1.5.31.

After this, proceed with the installation described in the Pub.dev section below.

Android version < 5.0 (API 21) and Usercentrics version < 2.13.0

If you support an Android version lower than 5.0 (API 21) and you don't have the multidex enabled in your project, you may see the following error when you run your app on Android:

D8: Cannot fit requested classes in a single dex file (# methods: 66055 > 65536)

You can change the minimum version of your application to 5.0 (API 21). That configuration is usually in the android/app/build.gradle file. Make sure that minSdkVersion is 21 or higher.

Although Android 5.0 version already supports 99% of all devices, if you still want to have support for Android 4.1 (API 16) you have to do the following:

  1. Add the multidex library to your application dependencies that is usually in the android/app/build.gradle file.

    implementation "androidx.multidex:multidex:2.0.1"

  2. Enable the option in the application build defaultConfig. It is usually in the same android/app/build.gradle file.

    multiDexEnabled true


  3. Make your application class initialize multidex. There are several options to do that, in Flutter the easiest way is to add it to the manifest. The manifest is usually located at android/app/src/main/AndroidManifest.xml.

    android:name="androidx.multidex.MultiDexApplication"


    After this, proceed with the installation described in the Pub.dev section below.

Android minimum SDK version

Support for versions lower than Android 5.0 (API Level 20) is planned to be removed in releases starting from April/24

iOS version < 11

If you have a iOS target version lower than 11 or you have no version at all (it defaults to version 9) you may see the following error when you run your app on iOS:

[!] Automatically assigning platform iOS with version 9.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

To solve this error, follow these steps:

  1. Define or increase the version of your Podfile at least to version 11. It is usually located at ios/Podfile.

    platform :ios, '11.0'


  2. Run flutter pub get again and open the iOS project using Xcode. It is usually located at ios/Runner.xcworkspace. Now, you have to select the Runner project and change the Deployment Target to the same version.

After this, proceed with the installation described in the Pub.dev section below.

Pub.dev

To install the SDK, add Usercentrics to your project via pub.dev:

flutter pub add usercentrics_sdk

🚀 You are now ready to start integrating Usercentrics.

iOS build system

The plugin supports both CocoaPods and Swift Package Manager (SPM) for its iOS dependencies — no extra setup is required for either. If your project has SPM enabled, run:

flutter config --enable-swift-package-manager

before flutter pub get, and Flutter resolves the plugin's iOS dependencies via SPM instead of CocoaPods. Existing CocoaPods-based projects continue to work unchanged.

React Native

Prerequisites

  • Android 7.0 (API 24) or higher with Kotlin 1.9 or higher

  • iOS 11 or higher

  • React Native 0.74.3 or higher (with Fabric support)

  • React 18.2 or higher (React 19 supported)

npm

To install the SDK, add Usercentrics to your project using npm:

npm i @usercentrics/react-native-sdk

🚀 You are now ready to start integrating Usercentrics.

Unity

The Usercentrics Unity SDK ships through two channels. Both are fully supported, both are built from the same sources, and both share the same asset GUIDs.

Channel

Artifact

iOS linkage

Unity Package Manager (npm registry)

com.usercentrics.sdk

Dynamic frameworks

Unity Package Manager (npm registry)

com.usercentrics.sdk.static

Static frameworks

Bitbucket Downloads

Usercentrics-2.X.X.unitypackage

Dynamic frameworks

Bitbucket Downloads

Usercentrics-2.X.X-static.unitypackage

Static frameworks

Already using the .unitypackage?

The .unitypackage is not deprecated and ships with every release — you do not have to migrate. If you want Package Manager to handle versioning for you, see Unity: Migrate to the Unity Package Manager.

Install exactly one Usercentrics SDK

Never the .unitypackage together with a Package Manager package, and never both Package Manager packages. They share asset GUIDs, so Unity silently ignores one of them — or both — and the SDK may not load at all.

Static Linkage Support for iOS

Because we use ExternalDependencyManager, the project output when building for iOS, will be a CocoaPods workspace, which offers an option to Link frameworks statically. If you need support for Static Linkage on iOS, use the static variant: the package com.usercentrics.sdk.static, or the download with the -static suffix. *e.g. Usercentrics-2.X.X-static.unitypackage.

The static variant needs Unity 2019.3 or newer for iOS builds, because it relies on the UnityFramework target that Unity only exports from 2019.3. Android builds are not affected.

Manual Linkage Support for iOS

In iOS, you have the flexibility to manually link frameworks when building your iOS applications, for instance, if you are using CMake for cross-platform development. If you need support for Manual Linkage, please download the latest version of the zip files:

  1. UsercentricsCore

  2. UsercentricsUI, containing the 'Manual-Linking' suffix. Please note if you need the -static version as well.

Installation on Unity IDE

Prerequisites

  • Android 5.0 (API 21), or higher, for the Minimum API Level and Android 12 (API 31) for the Target API Level

  • Java version 8 or 11 depending on the Unity Version

  • Kotlin 1.7 or higher

  • iOS 11 or higher

  • Unity 2018.4 or newer. Scoped registries need Unity 2019.1 or newer — on 2018.4, install the Package Manager package from a tarball as described below.

  • Version 2.36.0 or newer for the Package Manager packages. Earlier versions are only available as .unitypackage.

Install with Package Manager   BETA 

 BETA   Installing with Package Manager is in Beta. The Package Manager packages are available from version 2.36.0, the first release published to the npm registry. The package layout and the installation steps may change in a later release. The .unitypackage remains fully supported. If you run into a problem, please open a ticket with Usercentrics support.

  1. Install the External Dependency Manager (EDM4U). Unlike the .unitypackage, the Package Manager packages do not bundle it, and the SDK needs it to pull its native Android and iOS dependencies.

  2. Add the scoped registry and the dependency to Packages/manifest.json:

    {
      "scopedRegistries": [
        {
          "name": "Usercentrics",
          "url": "https://registry.npmjs.org",
          "scopes": [ "com.usercentrics" ]
        }
      ],
      "dependencies": {
        "com.usercentrics.sdk": "2.36.0"
      }
    }

    For static linkage on iOS, use com.usercentrics.sdk.static instead. One or the other, never both.

  3. Let Unity import the package. You can confirm it under Window - Package Manager.

  4. Resolve the native dependencies: Assets - External Dependency Manager - Android Resolver - Force Resolve.

    The first Force Resolve can fail

    On a project that has no Assets/Plugins/Android folder yet, the first Force Resolve fails with "Unable to copy 'mainTemplate.gradle'" and resolves nothing. This is an EDM4U behaviour, not a Usercentrics one. The failed attempt creates the folder, so run Force Resolve a second time.

Installing without a registry, or on Unity 2018.4

Scoped registries start at Unity 2019.1, and some projects cannot reach a registry at all. Download the tarball from the npm registry. The links below are for 2.36.0; for another version, replace 2.36.0 in the URL with the version you want (2.36.0 or newer):

https://registry.npmjs.org/com.usercentrics.sdk/-/com.usercentrics.sdk-2.36.0.tgz

https://registry.npmjs.org/com.usercentrics.sdk.static/-/com.usercentrics.sdk.static-2.36.0.tgz

With Node.js installed, npm pack com.usercentrics.sdk@2.36.0 downloads the same file. Place the tarball inside your project, and reference it by path instead:

"dependencies": {
  "com.usercentrics.sdk": "file:../LocalPackages/com.usercentrics.sdk-2.36.0.tgz"
}

For the static package, use com.usercentrics.sdk.static as the dependency name and its tarball's filename.

Everything else is identical. Updating means downloading a new tarball and changing the filename.

Install with the .unitypackage

  1. Drag and drop Usercentrics.unitypackage into your Unity project. Alternatively, you can select the package from the menu Assets - Import Package - Custom Package.
    If you have already imported ExternalDependencyManager for Unity in your project, you can deselect it in the pop-up, to keep your previous configuration.
    Import package window

  2. Click Import.

Add the prefab to your Scene

This step is the same for both installation methods.

Drag the Usercentrics prefab into your scene. This will represent the game object for the banner. With the .unitypackage the prefab is at Assets/Usercentrics/Prefabs; with the Package Manager package it is at Packages/com.usercentrics.sdk/Prefabs.
Drag & Drop

The name of this object needs to be Usercentrics

The native SDK delivers its callbacks to a GameObject with that exact name. If you rename it, the SDK initialises natively and then goes quiet: IsInitialized stays false, the banner never appears, and nothing is written to the log.

You are now ready to start integrating Usercentrics.

Troubleshooting

This section gives you some pointers on how to troubleshoot isses.

Unity Editor is NOT Supported

The Unity Editor is not supported. To test and debug the CMP you will need to run the project on a simulator or real device.

Troubleshooting an iOS setup

Cocoapods must be installed for iOS builds to work. Check their installation guide.

When opening the project built by Unity, you should always select the .xcworkspace file created by Cocoapods.

Troubleshooting an Android setup

Dependencies

When Android is selected as build platform, the dependency manager will ask you to download the dependencies that Usercentrics needs. We recommend enabling Android Auto-resolution to handle this. Make sure you have downloaded all Android Build Support Modules including OpenJDK.

Internet access

The Usercentrics SDK needs internet in order to initialize. Make sure you enable a required connection in your Android Player Settings.

You can do so under File - Build Settings - Android (selected) - Player Settings - Other Settings - Internet Access - Required.

ExternalDependencyManager and building

When using this plugin for the first time, a popup will appear asking if you want to enable Android Auto-resolution. We highly recommend to enable it, since it's natural for some Android libraries have conflicting dependencies. Auto-resolution can handle those conflicts for you.

Dependency conflicts (Duplicate classes) or ExternalDependencyManager fails to resolve dependencies

If the auto-resolution process fails to resolve any conflicts, modify your project's build configuration for Android. By doing so, you will not depend solely on the ExternalDependencyManager to download all dependencies. Instead, you allow Gradle to handle the resolution of dependencies and any emerging conflicts.

To do that, follow these steps:

  1. Go to File - Build Settings - Switch platform to Android,

  2. Go to Player Settings.

  3. Scroll to the last section Publishing Settings.

  4. Enable Custom Main Gradle Template.

  5. Enable Custom Gradle Properties File.

  6. Save & close.

  7. Go to Assets - External Dependency Manager - Android Resolver - Settings.

  8. Make sure Patch mainTemplate.gradle and  Patch gradleTemplate.properties are both enabled.