Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Vonage Video API Android SDK

The Vonage Video API Android SDK lets you use Vonage Video API-powered video sessions in apps you build for Android devices.

Important notes:

  • Android SDK 2.24.3+, 2.25.4+, and 2.26.0+ requires a mininum Android API level of 23.
  • Android SDK 2.24 and above no longer support 32-bit x86 architectures.
  • Applications targeting API level 31 and above now require permission READ_PHONE_STATE in addition to the other required permissions.

This page covers the following topics:


Overview

All applications that use the Vonage Video API are composed of two parts:

The client SDK for building Android apps is the OpenTok Android SDK, which provides most of the core functionality for your app, including:

You can learn more about the basics of OpenTok clients, servers, sessions, and more on the Video API Basics page.

Building with the OpenTok Android SDK

The best way to learn how to use the OpenTok Android SDK is to follow the OpenTok Basic Video Chat tutorial:

Start tutorial

Once you understand the basics of building with the OpenTok Android SDK, you can get more detailed information and learn how to customize your application with the OpenTok developer guides. To investigate specific API classes and methods, see the OpenTok Android SDK API reference.

Code samples

For sample code, visit our opentok-android-sdk-samples repo on GitHub.

Interoperability

Apps written with the OpenTok Android SDK 2.27.1 can interoperate with OpenTok written with version 2.25+ of the OpenTok client SDKs:

Installation

The library (an aar file) is included in the root of the SDK bundle.

A Maven version is available at https://search.maven.org/artifact/com.opentok.android/opentok-android-sdk. The artifact ID is "opentok-android-sdk". For more information, see Creating your own app using the OpenTok Android SDK.

Developer and client requirements

The OpenTok Android SDK supports one published audio-video stream, one subscribed audio-video stream, and up to five additional subscribed audio-only streams simultaneously (this is the baseline support on a Samsung Galaxy S3). To connect more than two clients in a session using the OpenTok Android SDK, create a session that uses the OpenTok Media Router (a session with the media mode set to routed). See The OpenTok Media Router and media modes.

The SDK is supported on high-speed Wi-Fi and 4G LTE networks.

The OpenTok Android SDK is supported on armeabi-v7a, armeabi64-v8a, and x86_64 architectures. Versions prior to 2.24.0 support the x86 architecture as well.

The OpenTok Android SDK works with any Android 6.0+ device (Marshmallow, API Level 23) that has a camera (for publishing video) and adequate CPU and memory support.

Creating your own app using the OpenTok Android SDK

The library is provided in the opentok-android-sdk-2.27.1.aar file. You no longer need to include architecture-dependent .so files (which was required in previous versions). This file is included in the root of the SDK package. Place the aar file into your project in Android Studio. Then modify the gradle file for your project to reference the aar file.

A Maven version is available at https://search.maven.org/artifact/com.opentok.android/opentok-android-sdk. The artifact ID is "opentok-android-sdk". Modify your app to download the OpenTok Android SDK from https://search.maven.org/artifact/com.opentok.android/opentok-android-sdk. For example:

  1. Edit the build.gradle for your project and add the following code snippet to the allprojects/repositories section:

mavenCentral()

  1. Modify the app's build.gradle file and add the following code snippet to the dependencies section:

implementation 'com.opentok.android:opentok-android-sdk:2.27.1'

  1. Make sure the app's build.gradle file contains the following code snippet within android section (starting from Android Studio 4.1 this snippet is present when creating a new project).

For Android SDK 2.22.0 and above:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
}

For Android SDK below 2.22.0:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

Your app needs to use a session ID and token generated with your OpenTok API key, which you can get by logging into your Vonage Video API account.

For test purposes, you can generate a session ID and token by logging into your Vonage Video API account. For a production app, generate unique tokens (and session IDs, if you need to support multiple sessions) using the OpenTok server-side libraries.

Permissions

The OpenTok Android SDK uses following permissions:

You do not need to add these to your app manifest. The OpenTok Android SDK adds them automatically. However, if you use Android 21+, certain permissions require you to prompt the user.

Your app can remove any of these permissions that will not be required. See this post and this Android documentation. For example, this removes the android.permission.CAMERA permission:

<uses-permission android:name="android.permission.CAMERA" tools:node="remove"/>

ProGuard rules needed by the Vonage Android SDK

The Vonage Android SDK uses the following packages:

The recommended ProGuard configuration is:

-keeppackagenames
-keep class com.opentok.** { *; }
-keep class com.vonage.** { *; }
-keep class org.webrtc.** { *; }
-keep class org.otwebrtc.** { *; }

When using Android Studio 3.4 or Android Gradle plugin 3.4.0+, shrinking, obfuscation and optimization are, by default, automatically enabled.

Shrinking and obfuscating the Vonage Android SDK is not recommended.

The configuration above forces the Vonage Android SDK source code to be kept, not disallowing the rest of the app to be shrunk.

Don't obfuscate the Vonage Android SDK to prevent conflicts with other libraries. Preserve the Vonage Android SDK package names with the flag -keeppackagenames.

The compiler automatically performs a set of optimizations by default. Any other optimizations are not recommended, but it is possible to enable additional optimizations, which may require to include additional ProGuard rules to avoid runtime issues, by adding the following in the project’s gradle.properties file:

android.enableR8.fullMode=true

Minifying the Vonage Android SDK is not recommended. Shrinking and obfuscating the Vonage Android SDK with the preceding optimization will generate warnings. These should be disabled.

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE

See this Android documentation to have a better understanding of the overall ProGuard rules and its functionalities.