Skip to main content

Android Elements SDK

Android Elements SDK


The Basis Theory Android SDK makes it easy to build secure Android applications that collect or reveal sensitive data using Elements.

Get started with our guide, explore our example application, or continue reading the reference docs.

Before You Begin

This SDK requires the use of an API Key associated with a Public Application, which only allows token:create or token:update permissions to mitigate the risk that these API keys may be publicly exposed within your frontend applications.

To create one, login into our Portal and create a new "Public" Application with the permissions you require.



  • Android 5.0+ (API level 21+)
  • AndroidX


Add the SDK dependency to your project's build file:

repositories {
maven { url '' }

dependencies {
implementation 'com.github.basis-theory:basistheory-android:<version>'

The latest release version can be found in GitHub.

If your build configuration enables code shrinking or obfuscation, these ProGuard rules are needed to use this SDK.

Additionally, the usage of anonymous objects to call some SDK methods such as tokenize, might lead to unexpected behavior. Creating dedicated classes along with ProGuard rules to preserve them solves the problem.

Basic Usage

Simply include one or more elements within your application's views:

android:layout_height="wrap_content" />

android:layout_height="wrap_content" />

android:layout_height="wrap_content" />

Then tokenize the user input by referencing these elements. This can be wired up in response to a button click, or any other user action.

val cardNumberElement = findViewById(
val cardExpirationDateElement = findViewById(
val cardVerificationCodeElement = findViewById(

val bt = BasisTheoryElements.builder()

runBlocking {
val tokenizeResponse = bt.tokenize(object {
val type = "card"
val data = object {
val number = cardNumberElement
val expiration_month = cardExpirationDateElement.month()
val expiration_year = cardExpirationDateElement.year()
val cvc = cardVerificationCodeElement

// send the tokens within tokenizeResponse to your backend

A full example Android app is included within the example module within the GitHub repo or explore all the supported Element Types.