Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
React JS
Unity
Unreal Engine
Unreal (Blueprint)

Compile and run a sample project

Agora provides Open-source sample projects on GitHub to demonstrate the implementation of basic and advanced Video SDK features.

This page shows how to compile, configure, and run the Video 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 camera and a microphone
  • Installed Git

Project setup

Get the sample project

Run the following command to clone the repository locally:


_1
git clone git@github.com:AgoraIO/API-Examples.git

This repository contains sample projects for all native platforms of Agora Video SDK. The API usage examples for Android are located under /Android.

PathDescription
/Android/APIExampleAPI usage examples of Agora Video SDK.
/Android/APIExample-AudioAPI usage examples of Agora Voice SDK.

Configure the sample project

information

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.

  1. 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.

  2. 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.


    _14
    <?xml version="1.0" encoding="utf-8"?>
    _14
    <resources>
    _14
    <!--
    _14
    Agora App ID
    _14
    -->
    _14
    <string name="agora_app_id" translatable="false">Your App ID</string>
    _14
    _14
    <!--
    _14
    Agora app certificate
    _14
    Note: Leave this field empty if the project allows joining by App ID only.
    _14
    -->
    _14
    <string name="agora_app_certificate" translatable="false">Your app certificate</string>
    _14
    _14
    </resources>

Run the sample project

  1. Open the /API-Examples/Android/APIExample folder in Android Studio.

  2. 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.

  3. In Android Studio, click Sync Project with Gradle Files for Gradle synchronization.

  4. After synchronization is complete, click Run 'app' to start compilation.

    The app is installed as Agora API Example on your device.

  5. 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.

  6. 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.

vundefined