Video Call
  • iOS
  • Android : Java
  • Web
  • Flutter
  • React Native
  • Electron
  • Unity3D
  • Cocos Creator
  • Windows
  • macOS
  • Linux
  • Overview
  • Develop your app
    • Quick start
    • Enhance basic feature
      • Use Tokens for authentication
      • Config your video based on scenes
      • Check the room connection status
      • Set up common video config
      • Set up common audio config
  • Best practices
    • Implement a video call for multiple users
    • Implement call invitation
    • Implement a live audio room
  • Upgrade using advanced features
    • Advanced features
      • Configure the video
        • Watermark the video/Take snapshots
        • Improve your appearance in the video
        • Beautify & Change the voice
        • Configure video codec
        • Output the video in H.265
      • Improve video quality
        • Configure bandwidth management
        • Test network and devices in advance
        • Visualize the sound level
        • Monitor streaming quality
      • Message signaling
        • Convey extra information using SEI
        • Broadcast real-time messages to a room
        • Quotas and limits
      • Play media files
        • Play media files
        • Play sound effects
      • Share the screen
      • Mix the video streams
      • Publish multiple video streams
      • Encrypt the video streams
      • Record video media data
    • Distincitve features
      • Join multiple rooms
      • Customize the video and audio
      • Set the voice hearing range
      • Transfer traffic via the cloud proxy server
      • Use the bit mask
      • Play streams via URL
      • Play a transparent gift special effect
      • AI Voice Changer
      • In-game voice chat
  • Upgrade using Add-on
  • Resources & Reference
    • SDK
    • Sample codes
    • API reference
      • Client APIs
      • Server APIs
    • Debugging
      • Error codes
      • Logging/Version number
    • FAQs
    • Key concepts
  • Documentation
  • Video Call
  • Resources & Reference
  • Sample codes
Sample code
Download

Sample source code running guide

This article describes how to quickly run the sample source code and experience basic audio and video calling services.

1 Prepare the environment

Before you attempt to integrate the ZEGO Express SDK, make sure that the development environment meets the following requirements (the following instructions are all based on a macOS computer):

  • Android Studio 2020.3.1 or later.

To know Android Studio's version changes, refer to the Android Studio release notes.

  • Android SDK 30, Android SDK Platform-Tools 30.xx or above.
  • Android devices or emulators with an Android version of 4.4 or above and support audio and video calling (real devices are recommended). If you use a real device, please enable the Allow Debugging option.
  • The Android device or macOS computer is connected to the Internet.
  • Android Studio automatically provides sample codes when you compile the sample source code for the first time, and there is no corresponding dependency library or build tool. This process may take a long time. Please wait patiently.
  • It is recommended that you download specific Gradle and required dependent libraries. Please refer to Gradle Services for download. The relevant versions of Gradle used in the sample source code are as follows:
  • Gradle: 6.7.1 (see the "project/gradle/wrapper/gradle-wrapper.properties" file).
  • Android Gradle Plugin: 4.2.0 (see the "project/build.gradle" file).

For version dependencies among Android Gradle Plugin, Gradle, and SDK Tool, please refer to Android Gradle Plugin Release Notes.

2 Prerequisites

Go to ZEGOCLOUD Admin Console to create a new project, and get the AppID and AppSign of your project.

The SDK now also supports using Token for authentication, if you want to change your authentication mode, refer to the Guide for upgrading the authentication mode from using the AppSign to Token.

3 Sample source code directory structure

The following directory structure is the file structure of the android_java subdirectory, and the file paths mentioned below are all relative to this directory.

.
├─ README.md
├─ README_zh.md
├─ VERSION.txt
└─ ZegoExpressExample
       ...
       ├─ AdvancedAudioProcessing    # Advanced audio features
       ├─ AdvancedStreaming          # Advanced stream publish and play
       ├─ AdvancedVideoProcessing    # Advanced video features
       ├─ CommonFeatures             # Common functions
       ├─ CommonTools
       ├─ DebugAndConfig             # Debug and configure
       ├─ KeyCenter                  # Fill in the AppID and AppSign of the application in the KeyCenter.Java file
       ├─ Others                     # Other functions
       ├─ Quickstart                 # Quick start
       ├─ Scenes                     # Best practices
       ├─ build.gradle
       ├─ gradle
       ├─ gradle.properties
       ├─ gradlew
       ├─ gradlew.bat
       ├─ local.properties
       ├─ log
       ├─ main
       │    ├─ .gitignore
       │    ├─ build
       │    ├─ build.gradle
       │    ├─ libs                # ZegoExpressVideo Android SDK storage directory
       │    ├─ proguard-rules.pro
       │    ├─ src
       │    └─ wrap
       └─ settings.gradle

4 Run the sample source code

  1. Find the Android Studio software icon on the development computer.
How to install Android Studio 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 Chinese operators and other factors, make sure that the computer can be connected to the Internet. If not, refer to method 2.
  • Method 2: Use a search engine to search for "Android Studio download", "Android Studio installation", and "Android Studio SDK Tools installation" to find the source website where you can download the software and tools and install them.
  1. Open Android Studio and click Open an Existing Project.

  2. In the decompressed example source code folder, select the ZegoExpressExample folder and open it.

    /Pics/Android/ExpressSDK/SampleRunningGuide/open_express_android_demo_new.png

  3. The AppID and AppSign required for SDK initialization are missing in the sample source code. You need to modify the KeyCenter.java file in the ./KeyCenter/src/main/java/im/zego/keycenter directory. Please refer to the Prerequisites. Make sure the AppID and AppSign are correctly filled in (Note: L needs to be added after the AppID). Otherwise, the sample source code cannot run properly.

/Pics/QuickStart/sample_code/sample_code_android.png

  1. Connect the Android device to the development computer. When you successfully enable the Developer mode and USB Debugging functions for the device, the Running Devices option box appears on Android Studio, as shown below:
    /Pics/Android/ExpressSDK/SampleRunningGuide/as_no_device_new.png
    Change to the following figure:
    /Pics/Android/ExpressSDK/SampleRunningGuide/as_connected_device_new.png
    This means that Android Studio has been successfully connected to the Android device, and the sample source code can be run on the device.
  • When the development computer is connected to an Android device, a prompt appears on most devices. Note that the prompt information varies based on Android manufacturers, and you can select the USB mode.
  • When the Android device is connected to the development computer, you need to enable the Developer mode and USB Debugging function on the device (the method for enabling the mode and function varies based on Android manufacturers). The developer needs to select a specific method. For example, if the developer mode and USB debugging function are not enabled for a certain device, you can use a search engine to search for "a device enables the developer mode" to view the specific enabling method and related tutorials.
  1. Click Run to compile and run the sample source code.
    /Pics/Android/ExpressSDK/SampleRunningGuide/run_android_demo_new.png

5 Experience audio and video calling/live broadcast function

We recommend you run your project on a real device. If your app runs successfully, you should hear the sound and see the video captured locally from your device.

To test out the real-time audio and video features, visit the ZEGO Express Web Demo, and enter the same AppID, Server and RoomID to join the same room. If it runs successfully, you should be able to view the video from both the local side and the remote side, and hear the sound from both sides as well.

In audio-only scenarios, no video will be captured and displayed.

FAQ

  1. Android Studio reports the following error: "Error: Illegal expression start: 9" when running the downloaded sample source code. How can this be resolved?

Since no specific values for AppID and AppSign exist in the downloaded sample source code, please refer to the Prerequisites in this article.

Page Directory