Setup - Android
Setting up android sdk
The Android SDK is a client for real-time communication on Android devices.
The SDK is Kotlin only. Call it from Kotlin code, built with Kotlin 1.8 or later. Most of its actions are suspend functions, so you call them from a coroutine.
Minimum OS/SDK versions
It supports the following OS/SDK versions.
Android: minSdkVersion >= 24
The SDK runs on Android 7.0 (API 24) or later, on ARM (arm64-v8a and armeabi-v7a) devices.
Installation
Step 1: Add the repositories.
The SDK is on Maven Central. With Android Studio Bumblebee or newer, add the repositories to settings.gradle.kts. With an older version, add them to the project's build.gradle.kts.
allprojects {
repositories {
// ...
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
// ...
google()
mavenCentral()
}
}
Step 2: Add the following dependency in your app's app/build.gradle.kts.
dependencies {
implementation("live.videosdk:rtc-android-sdk:3.0.0")
// lifecycleScope, to call the SDK's suspend functions from an activity
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
// other app dependencies
}
The SDK supports arm64-v8a and armeabi-v7a only. x86 / x86_64 emulator images are not supported. Test on an ARM phone or an arm64-v8a emulator image. If your app ships native libraries for other ABIs, set ndk { abiFilters 'arm64-v8a', 'armeabi-v7a' } in defaultConfig so the app is not installed where the SDK cannot load.
If you minify your app with R8 or ProGuard, add these rules for the SDK's videosdk.org classes. Keep the -dontwarn line: the keep rule alone fails the R8 step with a missing-class error.
-keep class videosdk.org.** { *; }
-dontwarn videosdk.org.**
Integration
Step 1: Add the following permissions in AndroidManifest.xml.
The SDK does not add INTERNET or MODIFY_AUDIO_SETTINGS to your app, so declare them yourself. ACCESS_NETWORK_STATE comes with the SDK; declaring it again is harmless.
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
RECORD_AUDIO, CAMERA, READ_PHONE_STATE and, on Android 12 and later, BLUETOOTH_CONNECT are runtime permissions, so also request them from the user. READ_PHONE_STATE is only needed for the external call events: without it, they never fire.
Step 2: Create MainApplication class which will extend the android.app.Application.
package live.videosdk.demo
import android.app.Application
import live.videosdk.rtc.android.VideoSDK
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
VideoSDK.initialize(applicationContext)
}
}
Step 3: Add MainApplication to AndroidManifest.xml.
<application
android:name=".MainApplication"
...
>
<!-- ... -->
</application>
Step 4: Create the room and join it.
In your call activity, create the room, ask for the camera and microphone permissions, then join. join() is a suspend function, so call it from a coroutine.
private lateinit var room: Room
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_join)
// generate the token on your server
val token = "JWT TOKEN GENERATED FROM SERVER"
try {
room = VideoSDK.createRoom(
roomId = "<room-id>",
token = token,
participantName = "John Doe",
micEnabled = true,
camEnabled = true,
)
} catch (e: VideoSDKException) {
// code 3073: the room ID or token is empty
Log.e("JoinActivity", "Could not create the room: ${e.message}")
return
}
VideoSDK.checkPermissions(
this,
listOf(Permission.audio, Permission.video),
permissionHandler = object : PermissionHandler() {
override fun onGranted() {
lifecycleScope.launch {
try {
room.join()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "Join failed: ${e.code} ${e.name}")
}
}
}
},
)
}
All set. See Creating a Room for every createRoom() parameter.
Got a Question? Ask us on discord

