Live Streaming
  • iOS
  • Android : Java
  • macOS
  • Windows
  • Linux
  • Web
  • Flutter
  • Electron
  • Unity3D
  • React Native
  • Cocos2D
  • Introduction
  • Sample codes
  • Client SDKs
    • SDK downloads
    • Release notes
  • Getting started
    • Integrate the SDK
    • Implement a basic live streaming
    • Use Tokens for authentication
  • Guides
    • Common video configuration
    • Common audio config
    • Real-time messaging
    • Enhancing live quailty
    • Stream mixing
    • Playing media files
    • Playing streams via URL
    • Basic face beautification features
    • Voice changing/Reverb/Stereo
    • Screen sharing
    • Local media recording
    • Advanced features
    • Quotas and Limits
  • Tutorials
  • Error codes
  • API Documents
  • FAQ

Integrate the SDK

Last updated:2022-11-17 11:51

Set up the development environment

Before integrating the ZEGO Express SDK, make sure the development environment meets the following requirements:

  • Android Studio 2020.3.1 or later
  • Android SDK Packages: Android SDK 25, Android SDK Build-Tools 25.0.2, Android SDK Platform-Tools 25.x.x or later.
  • An Android device or Simulator that is running on Android 4.4 or later and supports audio and video. We recommend you use a real device.
  • The Android device is connected to the internet.

Create a new project

Skip to this step if a project already exists.

Create a new project
  1. Open Android Studio, select File > New > Project.
  1. Configure your new project with Application name and Project location.

  2. All other items in the panel can be left as their defaults, click Next and then click Finish.

Import the SDK

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

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

Method 1: Integrate the SDK automatically with JitPack

  1. If your Android Gradle Plugin is v7.1.0 or later: go to the root directory of your project, open the settings.gradle file, and add the following line to the dependencyResolutionManagement:

    ...
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            maven { url 'https://jitpack.io' }
            google()
            mavenCentral()
        }
    }

If you can't find the above fields in settings.gradle, it's probably because your Android Gradle Plugin version is lower than v7.1.0.

For more details, see Android Gradle Plugin Release Note v7.1.0.

  • If your Android Gradle Plugin is earlier than 7.1.0: go to the root directory of your project, open the build.gradle file, and add the following line to the allprojects:

    ...
    allprojects {
        repositories {
            maven { url 'https://www.jitpack.io' }
            google()
            mavenCentral()
        }
    }
  1. Go to the app directory, open the build.gradle file, and add the following line to the dependencies. (x.y.z is the SDK version number, to obtain the latest version number, see ZEGO Express-Video Android SDK Release History)

    ...
    dependencies {
        ...
        implementation 'com.github.zegolibrary:express-video:2.+'
    }
  • Starting from the 2.7.0 version, ZEGO changes the SDK hosted server from JCenter to JitPack, so you need to change the configuration in build.gradle to com.github.zegolibrary:express-video:x.y.z.

  • JCenter will stop uploading the new version of the SDK after 2021-03-31, the service will be disabled 2021-05-01. For more details, see 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". We recommend all developers that use the old version switch to 1.11.0 or later version for integration.

Method 2: Manually add the SDK to the project

  1. Download the latest version of SDK. For details, see SDK downloads .

  2. Extract the files from the SDK packages into your project directory, for example, 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.

      The directory libs is only an example for illustration, you can fill in based on the actual situation.

    ```groovy
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    ```
  • Add the following code in the dependencies node.

      ```groovy
      dependencies {
          implementation fileTree(dir: 'libs', include: ['*.jar'])
          ......
      }
      ```

Add permissions

Permissions can be set as needed.

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" />

<!-- Permissions required by the App -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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 later, some important permissions must be requested at runtime rather than declared statically in the file AndroidMainfest.xml, therefore, you 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);
    }
}

Prevent class name obfuscation

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

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