Explore the Android (Kotlin) sample apps to further your knowledge of the Tealium library, tracking events, and best practice implementations.
Additionally, we recommend abstracting all the Tealium functionality in a central helper class. Explore our sample helper class.
Get the Code
Clone the Tealium Android library. Cloning the library, rather than downloading, makes it easier to update to future releases.
See the Tealium API for a complete listing of Tealium classes and methods for Android.
The Tealium Kotlin library is divided into modules. To maintain the smallest installation size possible, we recommended that you only install the modules necessary to achieve the desired functionality.
Install the Tealium Kotlin library with Maven or manually.
To install Tealium for Android library with Maven (recommended):
Add the Tealium Maven URL to your project’s top-level build.gradle file:
To initialize Tealium, configure a TealiumConfig instance and pass it into a Tealium instance. It’s recommended to initialize the Tealium Kotlin library in the app’s global application class within the onCreate() method.
Manage your Tealium instance by using a tracking helper class, which provides a single point of entry for the Tealium Kotlin library and simplifies future upgrades.
After transfer to the Kotlin library is complete, legacy data from the Java library is deleted. Subsequently switching back to the Java library results in a new tealium_visitor_id and app_uuid generated, and loss of any custom persistent data.
For Android Wear apps, use the Collect module for data collection, as the Tag Management module is not supported since Android Wear OS does not provide webview support.
If you are developing an Android Wear app using Tealium for Android, Google recommends creating a standalone app.
Android 9+ Multiprocess Applications
Android 9 introduced a behavior change around WebView data directories in multiprocess applications. In this change, a WebView no longer shares a single data directory across multiple processes. Typically, you’ll want to have all your Activities that use a WebView in the same process.
If you use the Tag Management module and implement additional instances of WebView, we recommend calling WebView.setDataDirectorySuffix() before creating the Tealium instance to prevent the app from crashing.
If you need to access cookies and web data from the Tag Management module, copy it between processes using the CookieManager.getCookie() and CookieManager.setCookie() methods.