Skip to main content

Android Getting Started

Requirements#

  • Latest stable Android Studio
  • Latest Gradle plugin
  • Latest NDK

Get the client token and configuration file#

To start working with the Banuba SDK in your project, you need to have the client token. To receive the client token please fill in our form on banuba.com website, or contact us via info@banuba.com.

Together with the token, you will receive a configuration file config.json which contains the required SDK resources defined by your token. Read more about this in Repack your SDK archive (minify SDK size) section.

note

Before building your project, place your client token inside the file: BanubaClientToken.java

Client token usage example#

BanubaClientToken.java
final class BanubaClientToken {
public static final String KEY = "YOUR_TOKEN_HERE";
private BanubaClientToken() {
}
}

Get the Banuba SDK archive#

With the client token, you will also receive the Banuba SDK archive for Android which contains:

  • Banuba Effect Player (compiled Android library project with .aar extension),
  • Banuba SDK (compiled Android library project with .aar extension),
  • Effect examples located under effects folder.

Repack your SDK archive (minify SDK size)#

The SDK release archive contains all SDK resources by default. They may consume more disk space in the ready build.

To reduce the SDK size please use sdk_repacking.py script provided with the SDK archive.

Please refer to SDK repacking readme in your SDK archive for more info and usage example.

Build your project with Banuba SDK#

  1. Create libs directory in your project and add banuba_effect_player.aar with banuba_sdk.aar.

image

  1. Open build.gradle (Module: app) and add Banuba SDK dependencies for your project

image

  1. Add BanubaClientToken.java to your project.

image

  1. In Project Structure check Declared Dependencies

image

  1. Also check our Android Demo app to use some code snippets

  2. Now you can run your project with BanubaSdk on your device

Minify the app size#

After integration of Banuba SDK libraries banuba_effect_player.aar, banuba_sdk.aar your app size may increase significantly. It may happen if you use an 'android.tools' version earlier than classpath com.android.tools.build:gradle:3.5.0. To minify your app size, update 'android.tools' to a newer version, e.g. classpath com.android.tools.build:gradle:4.0.1. Then, rebuild your application and check that "strip" phase exists in the build log (> Task :app:strip...).

Switching the face search mode#

The EffectPlayer xcframework allows you to use different face tracking algorithms for low, medium and high-end device classes.

Face tracking algorithms:

  • FAST โ€” provides higher performance yet lower quality of face tracking.
  • GOOD โ€” provides better tracking quality with larger resources usage.
  • MEDIUM โ€” special type which uses algorithm with optimal balance of quality and performance.

See more in API reference.

The default settings as seen below are GOOD for high-end and medium devices and MEDIUM for others.

BanubaSdkManager.java
FaceSearchMode faceSearchMode = FaceSearchMode.MEDIUM;
if (hardwareClass == HardwareClass.HIGH || hardwareClass == HardwareClass.MEDIUM) {
faceSearchMode = FaceSearchMode.GOOD;
}

You can change the code to force usage of any face tracking mode for the desired group of devices.

Last updated on