Run Example Source Code
Example Source Code Running Guide
- ZEGOCLOUD has unified the environment concept, and there is no distinction between formal and test environments. Users who created projects on ZEGOCLOUD Console on or before 2021-11-16, please refer to Test Environment Deprecation for SDK upgrade and related code adjustments.
- This example source code only includes basic stream publishing and playing operations for Voice Call. If you need examples of advanced features, please refer to Video Call Example Source Code (Voice Call SDK is obtained by removing video functions from Video Call SDK, and the APIs are basically the same).
Prepare Environment
Before integrating ZEGO Express SDK, please ensure that the development environment meets the following requirements (the following instructions use macOS development computer as an example):
- Android Studio 2020.3.1 or above.
- Android SDK 30, Android SDK Platform-Tools 30.x.x or above.
- Android 4.4 or above, and an Android device or emulator that supports audio and video (using a real device is recommended). If using a real device, please enable the "Allow USB debugging" option.
- The Android device and macOS development computer are connected to the Internet.
- When compiling the example source code for the first time, if there are no corresponding dependency libraries or build tools, Android Studio will automatically download them, which may take a long time. Please wait patiently.
- It is recommended to download specific Gradle and required dependency libraries. Please refer to Gradle Services for download. The Gradle related versions used in the example source code are as follows:
- Gradle: 6.7.1 (view in "project/gradle/wrapper/gradle-wrapper.properties" file).
- Android Gradle Plugin: 4.2.0 (view in "project/build.gradle" file).
For version dependencies between Android Gradle Plugin, Gradle, and SDK Tool, please see: Android Gradle Plugin Version Description
Prerequisites
You have created a project on ZEGOCLOUD Console and applied for a valid AppID and AppSign.
SDK also supports Token authentication. If you need to upgrade the authentication method, please refer to How to Upgrade from AppSign Authentication to Token Authentication.
Get Example Source Code
Local Download
Run Example Source Code
- Find the Android Studio icon on the development computer.

- Method 1: Log in to Android Studio Official Website to download and install Android Studio and its related SDK Tools. Due to network restrictions of domestic operators, developers need to ensure that their computer can access this website. If access is not possible, method 2 is recommended.
- Method 2: Use a search engine to search for "Android Studio download", "Android Studio installation", and "Android Studio SDK Tools installation" to find available download sources and install related software and tools.
-
Open Android Studio and click "Open an existing Android Studio project".

-
In the decompressed example source code folder, select the ZegoExpressExample folder and click "Open" to open it.

-
The example source code lacks the "appID" and "appSign" required for SDK initialization. You need to modify the "./KeyCenter/src/main/java/im/zego/keycenter" file. Please use the AppID and AppSign obtained in Prerequisites of this article to fill in correctly (Note: You need to add L after AppID), otherwise the example source code cannot run normally.
-
Connect the Android device to the development computer. When the device successfully enables "Developer Mode" and "USB Debugging" functions, you can see Android Studio change from the figure below:

To the figure below:

This indicates that Android Studio has successfully connected to the Android device, and the example source code can be run on the device.
- When the development computer connects to an Android device, most devices will pop up a prompt. The prompt information varies among different Android manufacturers. You can choose the USB mode according to the situation.
- After the Android device is connected to the development computer, you need to enable developer mode and USB debugging functions on the device according to the situation (the way to enable them varies among different Android devices). For specific enabling methods, you can use a search engine to search. For example: If there is a device that has never enabled developer mode and USB debugging, you can search "enable developer mode for device" in a search engine to view the specific tutorial.
- Click the "Build and run" button to compile and run the example source code.

If you encounter any problems during the running process, please contact ZEGOCLOUD Technical Support.
Experience Audio and Video Functions
Run the project on a real device. After successful operation, you can see the local video screen.
For convenience, ZEGO provides a Web platform for debugging. On this page, enter the same AppID and RoomID, enter different UserIDs, and the corresponding Token, you can join the same room and communicate with the real device. When the audio and video call starts successfully, you can hear the remote audio and see the remote video screen.
FAQ
- How to handle the error "Error: illegal start of expression :9" when running the downloaded example source code in Android Studio?

Since the AppID and AppSign in the downloaded example source code have no specific values, please refer to step 4 in the "Run Example Source Code" section of this article for processing.
- How to handle the error "Error: package im.zego.zegoexpress does not exist" when running the downloaded example source code in Android Studio?

Since accessing GitHub is slow in mainland China, the example source code downloaded from Github does not contain the "ZegoExpressEngine" SDK, so the specified package does not exist error will be reported. Please refer to step 4 in the "Run Example Source Code" section of this article for processing.
