The Vonage Video API Android SDK lets you use Vonage Video API-powered video sessions in apps you build for Android devices.
Important notes:
READ_PHONE_STATE
in addition to the
other required permissions.
This page covers the following topics:
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:
Client SDKs are also available for web, iOS, Windows, macOS, Linux, and React Native. All OpenTok client SDKs can interact with one another.
You can learn more about the basics of OpenTok clients, servers, sessions, and more on the Video API Basics page.
The best way to learn how to use the OpenTok Android SDK is to follow the OpenTok Basic Video Chat 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.
For sample code, visit our opentok-android-sdk-samples repo on GitHub.
Apps written with the OpenTok Android SDK 2.28.4 can interoperate with OpenTok apps written with version 2.25+ of the OpenTok client SDKs:
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.
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, x86, and x86_64 architectures.
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.
The library is provided in the opentok-android-sdk-2.28.4.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:
Edit the build.gradle for your project and add the following code snippet to the
allprojects/repositories
section:
mavenCentral()
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.28.4'
Modify the app's build.gradle file and add the following code snippet to the
android
section:
For Android SDK above 2.28.1:
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
For Android SDK between 2.22.0 and 2.28.1:
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.
The OpenTok Android SDK uses following permissions:
android.permission.BLUETOOTH_CONNECT
-- You need to enable this for API level 31 and above. If you want
to use the Bluetooth device with Android SDK DefaultAudioDevice targeting API level 31 and above, please
ask for runtime permissions in the app or enable the ("Nearby devices/Bluetooth") permission manually in
the app settings.
android.permission.READ_PHONE_STATE
-- The OpenTok Android SDK requests this permission in API level 22
and lower, and 31 and above.
android.permission.CAMERA
-- If your app does not use the default video capturer
and does not access the camera, you can remove this permission.
android.permission.INTERNET
-- Required.
android.permission.RECORD_AUDIO
-- If your app does not use the default audio
device and does not access the microphone, you can remove this permission.
android.permission.MODIFY_AUDIO_SETTINGS
-- If your app does not use the default audio
device and does not access the microphone, you can remove this permission.
android.permission.BLUETOOTH
-- The default audio device supports
Bluetooth audio. If your app does not use the default audio device and does not
use Bluetooth, you can remove this permission.
android.permission.BROADCAST_STICKY
-- We have determined that this is unused by
the OpenTok Android SDK, and we will remove this permission from an upcoming release.
You do not need to add these to your app manifest. The OpenTok Android SDK adds them automatically. However, in API level 21 and higher, 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"/>
The recommended ProGuard configuration is:
-keeppackagenames
-keep class com.opentok.** { *; }
-keep class com.vonage.** { *; }
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.
Preserve the Vonage Android SDK package names with the flag -keeppackagenames to prevent conflicts with other libraries.
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
The Vonage Android SDK supports 32-bit and 64-bit architectures for both ARM and x86 platforms.
See this Android documentation to have a better understanding of the overall ProGuard rules and its functionalities.