Client SDK


The Braintree Android SDK helps you accept payments in your Android app.


  • Android API >= 21

It goes without saying, but we'll say it anyway: we always recommend using the latest versions of our SDKs.


Our Android SDK and its modules follow semantic versioning. When updating your integration, be sure to update each module to the latest version.


There are several ways to include Braintree in your project, but Gradle is the preferred build system for working with the Braintree Android SDK.

Get the SDKanchor

In your build.gradle, add the dependencies for only the Braintree payment features you wish to use:

  1. Groovy
dependencies {
    // to offer card payments
    implementation 'com.braintreepayments.api:card:4.27.2'

    // to collect device data
    implementation 'com.braintreepayments.api:data-collector:4.27.2'

    // to offer PayPal 
    implementation 'com.braintreepayments.api:paypal:4.27.2'

    // to offer local payments
    implementation 'com.braintreepayments.api:local-payment:4.27.2'

    // to offer Google Pay
    implementation 'com.braintreepayments.api:google-pay:4.27.2'

    // to offer Union Pay
    implementation 'com.braintreepayments.api:union-pay:4.27.2'

    // to perform 3DS verification 
    implementation 'com.braintreepayments.api:three-d-secure:4.27.2'

    // to offer Venmo
    implementation 'com.braintreepayments.api:venmo:4.27.2'

Browser switch setupanchor

Some of our payment flows utilize a browser switch. A URL scheme must be defined to return to your app from the browser.

Edit your AndroidManifest.xml to include an intent-filter and set the android:scheme on your Activity that will be responsible for handling the deep link back into the app:

  1. Xml
<activity android:name=""
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="${applicationId}.braintree" />

The android:exported attribute is required if your app compile SDK version is API 31 (Android 12) or later.


Your app's URL scheme must begin with your app's package ID and end with .braintree. For example, if the Package ID is com.your-company.your-app, then your URL scheme should be com.your-company.your-app.braintree. ${applicationId} is automatically applied with your app's package when using Gradle.

Note: The scheme you define must use all lowercase letters. If your package contains underscores, the underscores should be removed when specifying the scheme in your Android Manifest.


Each payment method type has its own feature client. To initialize any of the feature clients, first instantiate a BraintreeClient:


You will need a form of authorization to create BraintreeClient. When constructing a BraintreeClient, you can provide a tokenization key or a ClientTokenProvider for client token authorization. When given a ClientTokenProvider, the SDK will fetch a client token on your behalf when it is needed. This makes it possible to construct a BraintreeClient instance using client token authorization in onCreate.

The example below shows the initialization with a tokenization key authorization:

  1. Kotlin
  2. Java
class MyActivity : AppCompatActivity() {

  private lateinit var braintreeClient: BraintreeClient

  override fun onCreate(savedInstanceState: Bundle?) {
    braintreeClient = BraintreeClient(this, "<#TOKENIZATION_KEY#>")

Client Token Provideranchor

Below is an example of ClientTokenProvider implementation using Retrofit 2.x. This example assumes that you have a server that supports GET and receives the following json response:

  1. JSON
    "value": "<CLIENT_TOKEN>"
  1. Kotlin
  2. Java
// In ClientToken.kt file taht you create
class ClientToken {
    val value = null

// In Api.kt file that you create
interface Api {

    fun getClientToken(): Call<ClientToken>

// In ExampleClientTokenProvider.kt file that you create
internal class ExampleClientTokenProvider : ClientTokenProvider {
    override fun getClientToken(callback: ClientTokenCallback) {
        val call: Call<ClientToken> = createService().getClientToken()
        call.enqueue(object : Callback<ClientToken?> {
            override fun onResponse(call: Call<ClientToken?>?, response: Response<ClientToken?>?) {
                response?.body()?.value?.let { callback.onSuccess(it) }

            override fun onFailure(call: Call<ClientToken?>?, t: Throwable?) {

    companion object {
        private val builder = Retrofit.Builder()
        private val httpClient = OkHttpClient.Builder()
        fun createService(): Api {
            val retrofit =
            return retrofit.create(

In an Activity or Fragment, create an instance of BraintreeClient using your ClientTokenProvider:

  1. Kotlin
  2. Java
class ExampleActivity : AppCompatActivity() {

    private lateinit var braintreeClient: BraintreeClient

    override fun onCreate(savedInstanceState: Bundle?) {
        braintreeClient = BraintreeClient(this, ExampleClientTokenProvider())


A ProGuard configuration is provided as part of the Braintree Android SDK. There is no need to add any Braintree specific rules to your ProGuard configuration.

See also