Run the sample code
Last updated:2024-12-26 18:54
Prerequisites
Before you begin, make sure you complete the following steps:
- Get the latest version of the SDK and sample code in SDK downloads.
- Contact the ZEGO team to get the AppID and AppSign for online privilege authentication.
- Get the unique license file of the Effects SDK. For details, see Online privilege authentication.
Make sure your development environment meets the following requirements:
- Android Studio 4.0 or later.
- Android SDK 30, Android SDK Platform-Tools 30.x.x or later.
- An Android device or emulator that is running on Android 9.0 (or later) and supports audio and video. We recommend you use a real device. If you use a real device, enable the Developer Options and USB Debugging.
- When compiling the sample code for the first time, Android Studio may take a while to download the missing dependencies or build tools.
- We recommend you use the following Gradle version and dependent libraries. For more information about Gradle, see Gradle Services .
- Gradle: 6.8.1 (specified in the file
project/gradle/wrapper/gradle-wrapper.properties
).
- Gradle Android plugin: 4.1.2 (specified in the file
project/build.gradle
).
Run the sample code
- If you haven't done so already, download and install Android Studio.
Open Android Studio and click Open an existing Android Studio project.
Select the ZegoEffectsExample folder in the unzipped sample code package, and click Open.
Add SDK dependencies and resources.
- Copy the "arm64-v8a" folder, "armeabi-v7a" folder, "x86_64" folder and "ZegoEffects.jar" file from the SDK directory after downloading to the "Example > ZegoEffectsExample > SDKManager > libs" path.
- Copy or replace the Models and Resources folders from the root directory to the "Example > ZegoEffectsExample > EffectsOnly > src > main > assets" path.
Specify the license information (AppID and AppSign), which is required for initializing the SDK.
a. Obtain the AppID and AppSign according to the 2 Prerequisites.
b. Modify the ZegoLicense.java
file in the ZegoEffectsExample/SDKManager/src/main/java/im/zego/zegoeffectsexample/sdkmanager
directory to specify the license information.
c. Find the "app/build.gradle" file and modify applicationId
to the package name used when applying for license.
Connect your Android device (make sure Developer options and USB debugging are enabled) to your development computer. Once the device is successfully connected, it will appear in the target device drop-down menu in Android Studio. Then, you can select it as the target device to run the sample code.
Before the device is connected:
After the device is connected:
- When you connect your PC to an Android device, a message will pop up on most devices. The message varies according to Android vendors. You can select USB mode based on the actual situation.
- When the Android device is connected to your PC, you will need to enable developer mode and USB debugging on the device as required (different Android devices can be enabled in different ways). You can also search for the methods when needed. For example, if the developer mode and USB debugging features are not enabled on a certain device, you can search for Developer mode on XX device for the specific tutorial.
- Click the Run button to build and run the sample code.