Compile and run a sample project
Agora provides Open-source sample projects on GitHub to demonstrate the implementation of basic and advanced Voice SDK features.
This page shows how to compile, configure, and run the Voice SDK Android sample project.
Prerequisites
- Android Studio 4.2 or higher.
- Android SDK API Level 21 or higher.
- Two mobile devices running Android 5.0 or higher.
- A computer with Internet access. If a firewall is deployed in your network environment, refer to Connect through restricted networks with Cloud Proxy to use Agora services normally.
- A microphone
- A valid Agora account and project
- Installed Git
Project setup
Get the sample project
Run the following command to clone the repository locally:
This repository contains sample projects for all native platforms of Agora Video SDK. The API usage examples for Android are located under /Android
.
Path | Description |
---|---|
/Android/APIExample | API usage examples of Agora Video SDK. |
/Android/APIExample-Audio | API usage examples of Agora Voice SDK. |
Configure the sample project
This page refers to the video sample project. If you want to run the audio sample project, please refer to the following steps and operate in the audio folder.
-
Integrate the SDK and install dependencies
The
/APIExample/app/build.gradle
file contains the project dependencies. When you open the project in Android Studio, it automatically downloads the dependencies and integrates the SDK. -
Set App ID and app certificate
Open the
/APIExample/app/src/main/res/values/string-config.xml
file and fill in the App ID and app certificate you obtained from the Agora Console.
Run the sample project
-
Open the
/API-Examples/Android/APIExample
folder in Android Studio. -
Turn on developer options on your Android device, enable USB debugging, and connect the device to the development machine through a USB cable. Your Android device appears in the Android device options.
-
In Android Studio, click Sync Project with Gradle Files for Gradle synchronization.
-
After synchronization is complete, click Run 'app' to start compilation.
The app is installed as Agora API Example on your device.
-
Open the app and choose the example you want to run. For example, to test Live Interactive Video Streaming, select the option from the menu, enter the channel name, and click Join.
-
To test various audio and video interaction scenarios, connect to the Agora web demo, or install and run the sample project on a second device. Make sure you use the same app ID on both devices. When you join the same channel from two devices, you can see and hear each other.