Setting up Your Development Environment

Prerequisites

Before getting started, connect ports and whitelist domains as described in Firewall Requirements.

You can also download Agora Video SDK for Android and set up the environment. The only difference between a Voice SDK and Video SDK is that the latter contains both voice and video functions. For details, see Setting up Your Development Environment.

Creating an Agora Account and App ID

  1. Create a developer account at www.agora.io. When you finish the sign-up, the website displays your Dashboard .

  2. Click Add New Project on the Projects page of the dashboard.

  3. Fill in the Project Name and click Submit .

  4. Copy the value of your App ID .

  5. In the Android Studio project, locate the app/src/main/res/values/strings.xml file and add the APP ID:

    ../_images/video_appid.png

Adding the Agora SDK to Your Project

  1. Open the build.gradle file under the app folder from the Project Files view in Android Studio. Make a note of the path of the libs folder to the right of compile fileTree. This is where you will put the Agora SDK for Android files later on.

    ../_images/video_buildgradle.png
  • The libs path directory is relative to the application’s app directory.
  • Ensure the path name contains no Chinese characters. Otherwise, if the path contains Chinese characters, compiling the code fails and displays an error message that contains random ASCII characters.
  1. Download the Agora Voice SDK for Android.

  2. Copy the contents of the libs folder from the SDK to the libs folder whose path you found earlier in the build.gradle file. The following table lists the contents of the libs folder.

    File/Folder Name Notes
    agora-rtc-sdk.jar .jar file (required)
    armeabi-v7a folder
    x86 folder
    arm64-v8a folder
    include folder

Adding the sourceSets

In the build.gradle file, add the sourceSets to the Android JSON object. Set the path for libs to the relative path for the libs app directory.

android {

...

sourceSets{
 main {
   jniLibs.srcDirs = ['../../../libs']
 }
}

}

Synchronizing the Project

Click Sync Project With Gradle Files until the sync is complete.

../_images/android9.png

Configuring the Android NDK

If you see the following “NDK not configured” error message, download and install the Android NDK.

../_images/android6.png
  1. Click the Configure button menu and select Project Defaults > Project Structure as shown below:

    ../_images/project_structure.png
  2. Copy the Android NDK into the Android NDK location listed in the Android Studio's Project Structure window.

    ../_images/android7.png
  3. Re-sync the Android project with the NDK files by clicking Sync Project With Gradle Files .

    ../_images/android9.png

Adding Device Permissions

  1. Open the AndroidManifest.xml file located under app > src > main and Add the required device permissions to the file.

     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="io.agora.openvideocall">
    
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.RECORD_AUDIO" />
      <uses-permission android:name="android.permission.CAMERA" />
      <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
      ...
    
      </manifest>
  2. Re-sync the Android project with the NDK files by clicking Sync Project With Gradle Files .

    ../_images/android9.png

Preventing Obfuscation of the Agora Classes

In the proguard-rules.pro file, add a -keep class configuration for the Agora SDK. This prevents obfuscation of the Agora SDK public class names.

-keep class io.agora.**{*;}

The Android environment is now set up to use the Agora Voice SDK.