Real-time Audio and Video
  • Platform
  • Framework / Engine
  • iOS
  • Android
  • macOS
  • Windows
  • Linux
  • Web
  • WeChat Mini Program

Integrating the SDK

Update Time:2021-02-22 18:00

1 Set up the Development Environment

Please ensure that the development environment meets the following technical requirements:

  • Android Studio 2.1 or higher
  • Android SDK Packages: Android SDK 25, Android SDK Build-Tools 25.0.2, Android SDK Platform-Tools 25.
  • An Android Device running on Android 4.1 or higher version with a camera and microphone. You can choose to run your project on an Android emulator, but using a real device is recommended.
  • The Android device and your computer are connected to the Internet.

2 Integrate the SDK into Your Project

2.1 Choose either of the following methods to integrate the ZEGO Express SDK into your project.

The Android ABIs currently supported by the SDK: armeabi-v7a, arm64-v8a, x86, x86_64.

Method 1: Integrate the SDK Automatically with JCenter

  1. Add the following line to your app/build.gradle file:

    ...
    dependencies {
        ...
        // please specify the SDK version number (e.g. 1.11.0)
        // The latest version number can be found in the SDK release history
        implementation 'im.zego:express-video:x.y.z'
    }

Please refer to the ZEGO Express-Video Android SDK Release History for the latest version.

Note: Starting from 1.11.0 version, if the SDK is integrated through Jcenter, the dependent commands change from implementation 'im.zego:express-engine-video: x.y.z' to implementation 'im.zego:express-video: x.y.z'. Customers using older versions are not affected, but no subsequent updates will be done for the express-engine-video packages. So, it is recommended that all customers using versions 1.11.0 or above switch to integrate the express-video packages.

If you want to use the Express-Video SDK that has the with whiteboard feature, please use the following command: implementation 'im.zego:express-video-whiteboard: x.y.z'.

Method 2: Download and Copy the SDK Files Manually

  1. Download the ZEGO Express-Video Android SDK and unzip the downloaded SDK package.

  2. Copy the unzipped .jar file and all the folders containing the .so files to your project directory (e.g. app/libs).

  3. Add SDK Import Statements. Open the file app/build.gradle, and add the following contents:

    • Add the ndk node inside the defaultConfig node to specify the supported ABIs.

      ndk {
         abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
      }
    • Add the sourceSets node inside the android node to specify the directory containing the SDK files.

      sourceSets {
         main {
             jniLibs.srcDirs = ['libs']
         }
      }

      /Pics/Android/ZegoLiveRoom/ZegoLiveRoom-IntegrationGuide/3_2_insert_sourceSets_node_2.png

    • Add the following code in the dependencies node

      implementation fileTree(dir: 'libs', include: ['*.jar'])

      /Pics/Android/ZegoLiveRoom/ZegoLiveRoom-IntegrationGuide/3_2_insert_sourceSets_node_3.png

2.2 Set up Permissions

Open the file app/src/main/AndroidManifest.xml, and add the following code:

<!-- Permissions required by the SDK -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <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.BLUETOOTH" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Permissons required by the App -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

Note: For Android 6.0 or higher, some important permissions must be requested at runtime rather than declared statically in the file AndroidMainfest.xml , therefore you also need to add the following code to do so (requestPermissions is a method of an Android Activity)

String[] permissionNeeded = {
        "android.permission.CAMERA",
        "android.permission.RECORD_AUDIO"};

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (ContextCompat.checkSelfPermission(this, "android.permission.CAMERA") != PackageManager.PERMISSION_GRANTED ||
        ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(permissionNeeded, 101);
    }
}

2.3 Prevent Class Name Obfuscation

To prevent the Zego SDK public class names from being obfuscated, please add the following code in the file proguard-rules.pro.

-keep class **.zego.**{*;}

After integrating the SDK, you can proceed to initialize the SDK. Use the next/previous buttons below or the side navigation bar on the left to navigate to the related documents.

  • QuickStart - Initializing the SDK