Skip to main content
Version: 0.1.x

Integrating React Native SDK for Android

The React Native SDK encapsulates our React JS SDK, streamlining dependency management for a more efficient development experience.

Step 1: Install the SDK.

The simplest way to get started is by installing the SDK in your application using the provided command:

npm install "@videosdk.live/react-native-sdk" "@videosdk.live/react-native-incallmanager"
caution
  • If you are using a Windows machine, make sure to include the double-quotes while installation.

  • If you are facing Error: unable to get local issuer certificate, below is the solution for the same

# for CMD
set NODE_TLS_REJECT_UNAUTHORIZED=0

# for PowerShell
$env:NODE_TLS_REJECT_UNAUTHORIZED="0"

Step 2: Include the following lines in your android/app/build.gradle file:

android/app/build.gradle
dependencies {
implementation project(':rnwebrtc')
}

Step 3: Include the following lines in your android/settings.gradle file:

android/settings.gradle
include ':rnwebrtc'
project(':rnwebrtc').projectDir = new File(rootProject.projectDir, '../node_modules/@videosdk.live/react-native-webrtc/android')

Step 4: Include the following lines in your MainApplication.java file:

MainApplication.java
import live.videosdk.rnwebrtc.WebRTCModulePackage;

public class MainApplication extends Application implements ReactApplication {
private static List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new WebRTCModulePackage());
return packages;
}
}

Step 5: Include the following line in your android/gradle.properties file:

android/gradle.properties
/* This one fixes a weird WebRTC runtime problem on some devices. */
android.enableDexingArtifactTransform.desugaring=false

Step 6 (OPTIONAL): Include the following lines in your android/app/proguard-rules.pro file (optional: if you are using Proguard):

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

Step 7: Update your AndroidManifest.xml file for permissions.

AndroidManifest.xml
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cool.app"
>
<!-- Provide all the required permissions to app -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Needed to communicate with already-paired Bluetooth devices. (Legacy up to Android 11) -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />

<!-- Needed to communicate with already-paired Bluetooth devices. (Android 12 upwards)-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

Step 8: Register the services in the index page of your project

import { register } from '@videosdk.live/react-native-sdk';
import { AppRegistry } from 'react-native';
import { name as appName } from './app.json';
import App from './src/App.js';

// Register the service
register();

AppRegistry.registerComponent(appName, () => App);

Minimum OS/SDK versions

In your build.gradle file, update the minimum OS/SDK version to 23.

buildscript {
ext {
minSdkVersion = 23
}
}

Got a Question? Ask us on discord