Demo Source Code Running Guide
This article introduces how to quickly run the demo source code and experience the basic audio and video call service.
Prepare Environment
Before integrating ZEGO Express SDK, please ensure that the development environment meets the following requirements (the following description takes 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 Android device or emulator that supports audio and video (real device is recommended). If using a real device, please enable the "Allow USB Debugging" option.
-
Android device and macOS development computer are connected to the Internet.
-
When compiling the demo source code for the first time, if there are no corresponding dependency libraries or build tools, Android Studio will automatically download the demo source code, which may take a long time. Please wait patiently.
-
It is recommended to download the specific Gradle and required dependency libraries. Please refer to Gradle Services to download. The Gradle-related versions used in the demo source code are as follows:
- Gradle: 6.7.1 (view in the "project/gradle/wrapper/gradle-wrapper.properties" file).
- Android Gradle Plugin: 4.2.0 (view in the "project/build.gradle" file).
For version dependencies between Android Gradle Plugin, Gradle, and SDK Tool, please see: Android Gradle Plugin Version Notes
Prerequisites
A project has been created in ZEGOCLOUD Console, and a valid AppID and AppSign have been applied for.
The 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 Demo Source Code
Local Download
Run Demo Source Code
- Find the Android Studio software icon on the development computer.

- Method 1: Log in to the 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 connect to this website. If they cannot access it, it is recommended to choose method 2.
- Method 2: Use a search engine to search for "Android Studio Download", "Android Studio Installation" and "Android Studio SDK Tools Installation", find available download sources, and install related software and tools.
-
Open Android Studio and click "Open an Existing Project".

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

- The demo source code lacks the "appID", "userID" and "token" required for SDK initialization. You need to modify the "./KeyCenter/src/main/java/im/zego/keycenter" file. Please use the AppID and Token obtained in the Prerequisites of this article to fill in correctly (Note: You need to add L after the AppID), otherwise the demo source code cannot run normally.
package im.zego.keycenter;
public final class KeyCenter {
// Developers can get appID from ZEGOCLOUD Console.
// https://console.zegocloud.com/dashboard
// for example:
// private long _appID = 123456789L;
private long _appID = ;
// Developers should customize a user ID.
// for example:
// private String _userID = "zego_benjamin";
private String _userID = "";
// Developers can get token from ZEGOCLOUD Console.
// https://console.zegocloud.com/dashboard
// Note: The user ID used to generate the token needs to be the same as the userID filled in above!
// for example:
// private String _token = "04AAAAAxxxxxxxxxxxxxx";
private String _token = "";
private static KeyCenter instance = new KeyCenter();
private KeyCenter() {}
public static KeyCenter getInstance() {
return instance;
}
public long getAppID() {
return _appID;
}
public void setAppID(long appID) {
_appID = appID;
}
public String getUserID() {
return _userID;
}
public void setUserID(String userID) {
_userID = userID;
}
public String getToken() {
return _token;
}
public void setToken(String token) {
_token = token;
}
}- Connect the Android device to the development computer. When the device successfully enables "Developer Mode" and "USB Debugging" functions, you can see the "Running Devices" option box at the top of Android Studio change from the following figure:
to the following figure:
This means Android Studio has successfully connected to the Android device, and the demo source code can be run on the device.
-
When the development computer is connected to an Android device, most devices will pop up a prompt. The prompt messages of different Android manufacturers are different. 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 (different Android manufacturers have different ways to enable them). For specific ways to enable them, developers can search by themselves using a search engine. For example: if there is a device that has not enabled Developer Mode and USB Debugging, you can search "Enable Developer Mode for a certain device" in a search engine to view the specific tutorial.
- Click the "Run" button to compile and run the demo source code.

Experience Real-time Audio and Video
Run the project on a real device. After successful running, 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 corresponding Token, and you can join the same room to 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
-
When Android Studio runs the downloaded demo source code, it reports an error "Error: Illegal expression start :9". How to handle it?

In the downloaded demo source code, AppID, UserID and Token do not have specific values. Please refer to step 5 in the "Run Demo Source Code" section of this article.
-
When Android Studio runs the downloaded demo source code, it reports an error "Error: Package im.zego.zegoexpress does not exist". How to handle it?

Since accessing GitHub in mainland China is relatively slow, the demo source code downloaded from Github does not contain the "ZegoExpressEngine" SDK, so it will report that the specified package does not exist. Please refer to step 4 in the "Run Demo Source Code" section of this article.
