Skip to main content
Version: 2.x.x

Android Setup - React Native

Follow below steps if you are setting up for Android​

The SDK's Android module is linked automatically, so you do not need to edit settings.gradle or MainApplication.

Step 1: Set the minimum SDK version to 24​

android/build.gradle
buildscript {
ext {
minSdkVersion = 24
}
}

Step 2: Update AndroidManifest.xml file​

Declare the permissions the SDK needs in your app's manifest.

android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Bluetooth audio devices -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
</manifest>

The SDK adds its own screen-share foreground service and the FOREGROUND_SERVICE and FOREGROUND_SERVICE_MEDIA_PROJECTION permissions, so screen share needs no manifest entries from you.

Step 3: Add below lines in the android/app/proguard-rules.pro (optional: if you are using Proguard)​

android/app/proguard-rules.pro
-keep class videosdk.org.** { *; }
-dontwarn videosdk.org.**

Keep both lines. The -keep rule alone fails the R8 step with a missing-class error.

Step 4: Ask for camera and microphone access​

On Android, the SDK does not ask the user for camera and microphone access. The camera and microphone do not start until your app has access, so call requestPermission() from useMediaDevice() before you join.

import { Button } from "react-native";
import { Constants, useMediaDevice } from "@videosdk.live/react-native-sdk";

function JoinButton({ onJoin }) {
const { requestPermission } = useMediaDevice();

const joinRoom = async () => {
const granted = await requestPermission(
Constants.permission.AUDIO_AND_VIDEO
);
if (
granted.get(Constants.permission.AUDIO) &&
granted.get(Constants.permission.VIDEO)
) {
onJoin();
}
};

return <Button title="Join" onPress={joinRoom} />;
}

To use Bluetooth audio devices on Android 12 and later, also call requestBluetoothPermission() from useMediaDevice().

Final Steps​

Import Example​

The easiest way to start is import @videosdk.live/react-native-sdk.

room.js
import {
useRoom,
RoomConsumer,
RoomProvider,
useParticipant,
RTCView,
createCameraVideoTrack,
} from "@videosdk.live/react-native-sdk";

Got a Question? Ask us on discord