Android SDK Overview

Prev Next

SDK Stats

Open Source Github Repo: https://github.com/BranchMetrics/android-branch-deep-linking

SDK Size: 187kb

Speed: Median 80ms to 250ms

Minimum OS Version: API Level 21+

Android Demo App

Want to take our technology for a test drive before implementing it?

DOWNLOAD BRANCH MONSTER FACTORY

Want to dive into the code directly?

VIEW BRANCH MONSTER FACTORY GITHUB

Basic Integration

Integrating the Branch Android SDK is required for the following features:

  • Ads

  • Email

  • Journeys

INTEGRATE THE BRANCH SDK

Advanced Features

On top of the basic integration, you can implement the following features:

  • Create content reference

  • Create deep link

  • Share deep link

  • Read deep link

  • Navigate to content

  • Display content

  • Track content

  • Track users

  • Handle push notifications

  • Handle links in your own app

IMPLEMENT ADVANCED FEATURES

Testing

Test your Branch integration before your app goes live.

TEST THE INTEGRATION

Troubleshooting

Running into issues? Browse our troubleshooting section to find a solution.

SEARCH SOLUTIONS

Version History

View past versions of the Branch SDK for Android including changes.

VIEW VERSION HISTORY

Full Reference

The information presented here serves as a reference manual for our Android SDK.

VIEW FULL REFERENCE

FAQ

Why do we recommend initializing the SDK in onStart() versus onCreate() in Android?

onCreate() is called when the Activity is first created and not when the activity is backgrounded. The Branch SDK is to be initialized every time the activity is foregrounded. If the activity is backgrounded and then foregrounded, this callback is not guaranteed to be called and hence the SDK will not be initialized.

The recommended way to initialize the Branch SDK is in onStart(). This is where you need to initialize the SDK since this callback is triggered every time the app is started whether from a cold start or a warm start. This is the callback that makes the activity visible to the user.

Why does my Android app crash when opening from a Branch link?

This mostly happens when there is a problem with the AndroidManifest.xml file. Please check to make sure that the entries added for App Links are not broken and are added inside the correct launcher activity.

Also, ensure that the entry for application name points to an existing Application class.

How do I know if my Android app links are configured properly?

You can check on which app links will open the app directly by doing the following:

Navigate to App Info > Advanced > Open by Default > Supported Links. This will show all the app links that are enabled for your app.

Why does my Android app call Branch multiple times when resuming?

This behavior is often a consequence of the launchMode parameter in the Android manifest being set incorrectly. Make sure that launchMode in the manifest is set as follows:

android:launchMode='singleTask'

When this is not set, or is set incorrectly, the activity may fire twice.

Why did Google Play remove my app from the store?

In older versions of the Branch Android SDK (1.2.6 to 2.11.0) calls were made to https://api.branch.io/v1/applist endpoint. We disabled and deprecated this endpoint in 2015, but it seems that it is not enough. We believe a recent update to the Google Play Store policies prompted these new violations. In response, Branch has removed all the potentially hostile code from our Android SDK and released an updated version on 8/14/17. This was limited to our Android SDK and our latest SDK complies with the privacy policies of the Play Store.

Please update your Android app to use the latest version (v 2.11.1) of the Branch SDK and re-submit it to the Play Store.

How does Charles Proxy relate to my Android app?

Since Android N, you are not able to proxy to apps unless it is your own app. What this means is:

  1. You need to download the .apk.

  2. Add the code in the instructions​.

  3. Recompile it.

How do I stop collecting the SSAID (android_id)?

The SSAID or android_id is a persistent hardware identifier that is “common between apps signed by the same developer signing key.” Branch utilizes this for many use cases such as Fraud and to provide the best user experience across different apps. If you wish for Branch not to collect the SSAID, you can call Branch.disableDeviceIDFetch() within onCreate() of your Application Class.

When this method is enabled, the SDK will fallback to generating a UUID as a hardware id.

Why does my app not open directly when it gives an option to choose between browser and app?

On Android, if the App Links are enabled correctly, they should never show the dialog box to choose between a browser and the app as mentioned in the Android documentation.

Troubleshooting Steps

  1. Confirm the device browser is NOT the default handler for xx.app.link domain.

    • Android App Links sets the app as the default handler for a domain (i.e., xx.app.link).  If a user clicks a link before App Links is enabled, they’ll have the option to open in browser or in-app.  If the browser is selected with “always”, that domain will never open the app.

    • Reset browser defaults: Settings → Apps → select the browser → Defaults → “Clear Defaults”.

  2. If one domain is failing verification, App Links is disabled for every other domain too.

    • Every domain & subdomain in Manifest must host a DAL file at: https://[domain]/.well-known/assetlinks.json

    • Even if autoVerify="true" is not in all intent filters, Android will scrape every domain.

  3. Confirm Branch dashboard & all other DAL files contain the correct SHA 256 fingerprint.

  4. Confirm app’s compileSdkVersion in build.gradle is 23+.

  5. All link domains must be publicly accessible (not behind firewall/vpn) and accessible by Google's bots.

  6. Validate App Links: Install app > connect device to Android Studio > ./adb shell dumpsys package d.

520

Successful verification

327

Failed verification