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
- Add the URL of the private Maven repository of ZEGOCLOUD to the
repositories
section in thesetting.gradle
orbuild.gradle
file.
repositories {
...
maven { url "https://storage.zego.im/maven" }
...
}
- Open the
app/build.gradle
file and add the following dependency to thedependencies
section:
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"
...
}
Method 2: Manual integration
-
Download the latest SDK and decompress the SDK. For more information, see Download.
-
Open the decompressed folder. Copy the
zegoaminigame.aar
file to theapp/libs
directory of your project. -
Open the
app/build.gradle
file and add the following dependencies to thedependencies
section:
...
dependencies {
...
implementation fileTree(dir:'libs', include: ['.jar', '.aar'])
...
...
implementation "com.google.code.gson:gson:2.8.8"
...
}
4. Grant permissions
Necessary permissions
Open the /app/src/main/AndroidManifest.xml
file and grant the following permissions to the SDK:
<!-- 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" />
The following table describes the permissions.
Required | Permission | Description | Why required |
---|---|---|---|
Yes | INTERNET | Permission required to access the internet. | You can use the basic features of the SDK only after you connect to the internet. |
ACCESS_WIFI_STATE | Permission 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_STATE | Permission 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:
<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" />
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: