logo
On this page

Integrate the SDK


Prepare the environment

Before you integrate ZEGOCLOUD MiniGameEngine SDK, make sure that the development environment meets the following requirements:

  • Android Studio 2021.2.1 or later is installed.
  • Android SDK 29 or later, Android SDK Build-Tools 29.0.2 or later, and Android SDK Platform-Tools 29.x.x or later are installed.
  • Android 5.0 or later is installed. An Android device that supports audio and video playback is available.
  • The Android device is connected to the internet.

Integrate SDKs

1. (Optional) Create a project

2. Import ZEGOCLOUD Express SDK

ZEGOCLOUD MiniGameEngine SDK must be used with ZEGOCLOUD Express SDK 3.1.1 or later. If your project is already integrated with ZEGOCLOUD Express SDK of a proper version, skip this step. Otherwise, integrate ZEGOCLOUD Express SDK by referring to the following topic:

3. Import ZEGOCLOUD MiniGameEngine SDK

You can integrate the SDK by using one of the following methods:

Method 1: Automatic integration

  1. Add the URL of the private Maven repository of ZEGOCLOUD to the repositories section in the setting.gradle or build.gradle file.
Untitled
repositories {
    ...
    maven { url "https://storage.zego.im/maven" }
    ...
}
1
Copied!
  1. Open the app/build.gradle file and add the following dependency to the dependencies section:
Untitled
dependencies { 
    ...
    // Replace x.y.z in the following sample code with the version number of ZEGOCLOUD MiniGameEngine SDK. For more information, see [Release notes](https://www.zegocloud.com/docs/mini-game-android/quick-start/release-notes).
    implementation "im.zego:minigameengine:x.y.z"
    ...
}
1
Copied!

Method 2: Manual integration

  1. Download the latest SDK and decompress the SDK. For more information, see Download.

  2. Open the decompressed folder. Copy the zegoaminigame.aar file to the app/libs directory of your project.

  3. Open the app/build.gradle file and add the following dependencies to the dependencies section:

Untitled
...
dependencies { 
    ...
    implementation fileTree(dir:'libs', include: ['.jar', '.aar'])
    ...
    ...
    implementation "com.google.code.gson:gson:2.8.8"
    ...
}
1
Copied!

4. Grant permissions

Necessary permissions

Open the /app/src/main/AndroidManifest.xml file and grant the following permissions to the SDK:

Untitled
<!-- Permissions mandatory for the SDK -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1
Copied!

The following table describes the permissions.

RequiredPermissionDescriptionWhy required
YesINTERNETPermission required to access the internet.You can use the basic features of the SDK only after you connect to the internet.
ACCESS_WIFI_STATEPermission required to obtain the Wi-Fi status.The SDK performs different operations when the network status changes. For example, when the system reconnects to the internet, the SDK restores the system to the state it was in when the network was disconnected. You do not need to perform any operations.
ACCESS_NETWORK_STATEPermission required to obtain the network status.

Optional permissions

To allow your project to support live streaming and voice chatroom scenarios, grant the following permissions related to camera and microphone to the SDK.

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

Untitled
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
1
Copied!

5. Configure obfuscation rules

ZEGOCLOUD MiniGameEngine SDK adopts code obfuscation. You do not need to add obfuscation rules for integrating ZEGOCLOUD MiniGameEngine SDK.

What to do next

After you perform the preceding steps, the SDKs are integrated with your project. Then, you can read the following docs to start streaming the live comment-based games:

Previous

Run sample codes

Next

Implement live comment-based games on PCs as a host