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

Integrating the SDK

Update Time:2021-05-06 10:51

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.

  • JCenter will stop uploading the new version of the SDK after 2021-03-31, the service will be disabled 2021-05-01, please refer to Service End for JCenter .
  • Starting from the 1.11.0 version, the dependent command has been changed from implementation 'im.zego:express-engine-video:x.y.z' to implementation 'im.zego:express-video:x.y.z' . The use of the version under 1.11.0 will not be affected, but the follow-up will not be updated from "express-engine-video". It is recommended that all developers using the old version switch to 1.11.0 or above Version for integration.

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

The "libs" directory in the sample code is just an example, developers can fill in according to the actual path.

  • Add the following code in the dependenc ies 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