Before integrating the ZEGO Express SDK, make sure the development environment meets the following requirements:
Skip to this step if a project already exists.
Open Android Studio, select File > New > Project.
Configure your new project with Application name and Project location.
All other items in the panel can be left as their defaults, click Next and then click Finish.
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.
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://storage.zego.im/maven' }
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://storage.zego.im/maven' }
google()
mavenCentral()
}
}
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 'im.zego:express-video:x.y.z'
}
Download the latest version of SDK. For details, see SDK downloads .
Extract the files from the SDK packages into your project directory, for example, app/libs
.
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.
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
Add the following code in the dependencies
node.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
......
}
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-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);
}
}
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.**{*;}