Search specific term/phrase surrounded by double quotes. e.g. “deep linking”
Exclude records that contain a specific term prefixed with a minus. e.g. Android -Firebase

Android Testing

Test Branch functionality and access tools to ensure you've successfully integrated our Android SDK.

Overview

The test scenarios, tools, and resources in this guide help you make sure that you've integrated the Branch Android SDK correctly.

To integrate the Branch Android SDK, follow the steps in our Android SDK Basic Integration guide.

Test Scenarios

Test Deep Linking

To test whether you can successfully use Branch Deep Links:

  1. Create a deep link using the Branch Dashboard.
  2. Make sure your test device is ready to use.
  3. Remove the app from your device and reset your advertising ID.
  4. Compile and re-install your app on the device.
  5. Paste the deep link in a different app on the device - somewhere that you'll be able to click the link from.
  6. Click the deep link. Your app should open and route you to the proper screen.

Test Deep Link Routing

To test deep link routing for your app:

  1. Append ?bnc_validate=true to a Branch Deep Link.
  2. Click on this deep link from your mobile device (not the Simulator).

An example link would look like: "https://<yourapp\>.app.link/NdJ6nFzRbK?bnc_validate=true"

Test Install

To ensure the SDK is setup correctly, you no longer need to simulate an install via the SDK itself.

Instead, you can test functionality end to end by completing the following:

  1. Add a test device to your Branch account.
  2. Test your campaign setup.

Testing Tools

Integration Status Tab

For a quick approach to checking your Branch Android SDK integration status and progress, you can use the Integration Status tab of the Branch Dashboard.

Integration Validator Method

Another simple way to test the status of your Branch Android SDK integration is using the built-in IntegrationValidator.validate() method.

To use this method, add the following code to your MainActivity's onStart():

IntegrationValidator.validate(this)
IntegrationValidator.validate(MainActivity.this);

This method will check to ensure that the Branch keys, package name, URI schemes, and link domain settings from the Branch Dashboard match those in the build.

Check your ADB Logcat to make sure all the SDK integration tests pass.

Make sure to comment out or remove IntegrationValidator.validate() in your production build.

For more about the IntegrationValidator.validate() method, visit our blog.

Branch Test Key

For testing purposes, you can use your Branch test key instead of your live key.

To use your test key:

  1. Add your test key to your AndroidManifest.xml file.

  2. Use the sample code below to update your app, noting the enableTestMode() method:

    package com.example.android
    
    import android.app.Application
    import io.branch.referral.Branch
    
    class CustomApplicationClass : Application() {
    	override fun onCreate() {
    		super.onCreate()
    
    		// Branch logging for debugging
    		Branch.enableTestMode()
    
    		// Branch object initialization
    		Branch.getAutoInstance(this)
    	}
    }
    
    package com.example.android;
    
    import android.app.Application;
    import io.branch.referral.Branch;
    
    public class CustomApplicationClass extends Application {
    	@Override
    	public void onCreate() {
    		super.onCreate();
    
    		// Branch logging for debugging
    		Branch.enableTestMode();
    
    		// Branch object initialization
    		Branch.getAutoInstance(this);
    	}
    }
    

Make sure the test key of your app matches the test key in the deep link, and that you remove the enableTestMode() method before releasing to production.

Enable Logging

Enable logging in your app to catch errors and other useful information coming from Branch. Make sure to only do this for testing, and that you remove the logging code before releasing to production.

Use the sample code below to update your app, noting the enableLogging() method:

package com.example.android

import android.app.Application
import io.branch.referral.Branch

class CustomApplicationClass : Application() {
	override fun onCreate() {
		super.onCreate()

		// Branch logging for debugging
		Branch.enableLogging()

		// Branch object initialization
		Branch.getAutoInstance(this)
	}
}
package com.example.android;

import android.app.Application;
import io.branch.referral.Branch;

public class CustomApplicationClass extends Application {
	@Override
	public void onCreate() {
		super.onCreate();

		// Branch logging for debugging
		Branch.enableLogging();

		// Branch object initialization
		Branch.getAutoInstance(this);
	}
}

Link Debugger

You can make sure your Branch Link is properly configured by using Branch's Link Debugger tool. It can help you determine whether the link was properly configured and passed the correct data when it was created.

To use Branch's Link Debugger:

  1. Sign in to your Branch Dashboard.

  2. Make sure you are in the proper environment for the link you want to debug (live or test).

  3. Copy the Branch Link, and append ?debug=1 to the end of it.

    1. For example, the Branch Link https://branchster.app.link/3vqEJflHrGb would become https://branchster.app.link/3vqEJflHrGb?debug=1
  4. Paste this link, including the ?debug=1 flag, into your browser. This will open the Link Debugger view:

This tool includes the Link Routing Debugger, which allows you to view the expected behavior for each operating system and click location.

To use the Link Routing Debugger:

  1. Select an operating system and location using the dropdown menus.

  2. View the redirect results table for the link.

Based on the operating system and click location you have selected, you’ll see the click redirect outcome for when a user does and does not have the app installed.

Additional Resources

Sample Applications

Troubleshooting Guide

If you're experiencing unexpected behavior with the Branch Android SDK, start by taking a look at our Troubleshooting guide.