# Classroom SDK & Proctor SDK (/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

This page introduces how to add Flexible Classroom into your app.


      
## Android

## Understand the tech

#### Module introduction

The source code of Flexible Classroom contains the following packages:

* `app`: (Optional) This module contains code for the classroom login interface and a client-side token generator and shows how to call APIs to join a flexible classroom. This module is an open-source project available on GitHub and for reference only.

<CalloutContainer type="info">
  <CalloutDescription>
    - Specifications defined for the login interface (such as the length requirement of the user name and the room name and character restrictions) do not apply to all apps – make sure to define them according to your business requirements.
    - The client-side token generator provided by Agora is only for rapid testing. When your app goes live, to ensure security, you must deploy a server-side token generator and generate tokens on your server. For details, see [Secure authentication with tokens](/en/realtime-media/flexible-classroom/build/set-up-your-account-and-authentication/authentication-workflow).
  </CalloutDescription>
</CalloutContainer>

* `AgoraEduUIKit`: (Optional) This module contains code for the classroom UI. It shows how to call APIs to aggregate and update UI data based on Flexible Classroom APIs and data callbacks. This module is an open-source project available on GitHub. You can develop your classroom UI based on this module.
* `AgoraClassSDK`: (Optional) This module provides methods to configure the SDK, launch a flexible classroom, register ext apps, and the activity implementation of each teaching use-case. This module is an open-source project available on GitHub. Agora recommends integrating this module.
* `AgoraEduCore`: (Required) The core module of Flexible Classroom. Since v2.0.0, this module is closed-source, and you can import this module only by adding a remote dependency.
* `AgoraCloudScene`: (Optional) The cloud classroom module of the Flexible Classroom. Depends on the `AgoraEduCore` cloud classroom UI implementation of the module.

## Integrated education use-case

If you use the default UI of Flexible Classroom, take the following steps to add remote dependencies and integrate the whole Flexible Classroom through Maven:

1. Add the following library to your project's `build.gradle` file:

   ```
   repositories {
       maven { url 'https://jitpack.io' }
       google()
       mavenCentral()
       maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
   }
   ```

2. Add the following dependencies in the project's `build.gradle` file to import the following modules: `AgoraEduUIKit`, `AgoraClassSDK`, and `AgoraEduCore`:

   ```
   dependencies {
       ...
       implementation "io.github.agora-apaas:AgoraEduCore:<version>"
       implementation "io.github.agora-apaas:AgoraEduUIKit:<version>"
       implementation "io.github.agora-apaas:AgoraClassSDK:<version>"
   }
   ```

   For example, for v2.8.20:

   ```
   dependencies {
       implementation "io.github.agora-apaas:AgoraEduCore:2.8.20"
       implementation "io.github.agora-apaas:AgoraEduUIKit:2.8.20"
       implementation "io.github.agora-apaas:AgoraClassSDK:2.8.20"
    }
   ```

   To use Flexible Classroom versions equal to or earlier than 2.7.0, also add the `hyphenate` dependency inside the `dependencies` block in the project's `build.gradle` file:

   ```
   dependencies {
       ...
       implementation "io.github.agora-apaas:hyphenate:<version>"
   }
   ```

<CalloutContainer type="info">
  <CalloutDescription>
    Click here to view the latest version of [Flexible Classroom](https://search.maven.org/search?q=io.github.agora-apaas).
  </CalloutDescription>
</CalloutContainer>

1. After version 2.8.70, the following code needs to be initialized in the Application `onCreate` method:

   ```kotlin
   AgoraSDKInitUtils.initSDK(this);
   ```

2. To launch a classroom, call [AgoraClassroomSDK.launch](/en/api-reference/api-ref/flexible-classroom/classroom-sdk#launch). Sample code:

   ```kotlin
   // Before starting the classroom, you need to dynamically apply for `Manifest.permission.RECORD_AUDIO` and `Manifest.permission.CAMERA` permissions
   fun startClassRoom() {
       val appId = "" // Your app ID
       val rtmToken = "" // Your signaling Token
       val userName = "Tom"   	 // Your user name
       val roomName = "MyRoom"  // Your room name
       val roomType = RoomType.SMALL_CLASS.value                     // Class type: 0: One-on-one, 2: Large class, 4: Small class
       val roleType = AgoraEduRoleType.AgoraEduRoleTypeStudent.value // Role: 1: Teacher role, 2: Student role
       val roomUuid = HashUtil.md5(roomName).plus(roomType).lowercase()
       val userUuid = HashUtil.md5(userName).plus(roleType).lowercase()
       val roomRegion = AgoraEduRegion.cn  // Area
       val duration = 1800L                // Class duration

       val config = AgoraEduLaunchConfig(
           userName,
           userUuid,
           roomName,
           roomUuid,
           roleType,
           roomType,
           rtmToken,
           null,
           duration
       )

       config.appId = appId
       config.region = roomRegion
       // Set large window video area parameters (large stream)
       config.videoEncoderConfig = EduContextVideoEncoderConfig(
           FcrStreamParameters.HeightStream.width,
           FcrStreamParameters.HeightStream.height,
           FcrStreamParameters.HeightStream.frameRate,
           FcrStreamParameters.HeightStream.bitRate
       )

       AgoraClassroomSDK.setConfig(AgoraClassSdkConfig(appId))
       AgoraClassroomSDK.launch(this, config, AgoraEduLaunchCallback { event ->
           Log.e("agora", ":launch-Class status:" + event.name)
       })
   }
   ```

   You can set the video parameters of the large and small windows by setting `FcrStreamParameters`, where:

   * Small stream mode: When in the stage area, switch to the small stream mode. This parameter indicates the video parameters in the stage area.
   * Large stream mode: When in the large window area, switch to the large stream mode. This parameter indicates the video parameters in the large window.

   ```kotlin
   public class FcrStreamParameters {
       // Small stream
       public static class LowStream {
           public static int width = 320;
           public static int height = 240;
           public static int frameRate = 15;
           public static int bitRate = 200;
       }

       // Large stream
       public static class HeightStream {
           public static int width = 640;
           public static int height = 480;
           public static int frameRate = 15;
           public static int bitRate = 600;
       }
   }
   ```

3. Set up dark mode

   Because switching to the dark mode requires restarting the Activity, in order to be compatible with all mobile phone models, it is recommended to set the theme directly in `Application#onCreate`. Refer to the following sample code:

   ```kotlin
   void setDarkMode() {
       // Add the logic of whether to enable the dark mode here
       boolean isDarkMode = ""
       if (isDarkMode) {
           SkinUtils.INSTANCE.setNightMode(true);
       }
   }
   ```

4. To prevent code obfuscation, add the following in the `/Gradle Scripts/proguard-rules.pro` file:

   ```java
   -keep class io.agora.**{*;}
   -keep class com.agora.**{*;}
   -keep class com.hyphenate.**{*;}
   ```

## Integrated cloud classroom

If you use the default UI of Flexible Classroom Cloud Classroom, take the following steps to add remote dependencies and integrate the whole Flexible Classroom through Maven:

1. Add the following code to the `build.gradle` file in the project root directory：

   ```kotlin
   repositories {
       maven { url 'https://jitpack.io' }
       google()
       mavenCentral()
       maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
   }
   ```

2. Add the following dependencies to the `build.gradle` file in the project root directory. Import `AgoraCloudScene` and `AgoraEduCore` module:

   ```kotlin
   dependencies {
       implementation "io.github.agora-apaas:AgoraEduCore:<version>"
       implementation "io.github.agora-apaas:AgoraCloudScene:<version>"
   }
   ```

   For example, for version 2.8.70:

   ```kotlin
   dependencies {
       implementation "io.github.agora-apaas:AgoraEduCore:2.8.70"
       implementation "io.github.agora-apaas:AgoraCloudScene:2.8.70"
    }
   ```

<CalloutContainer type="info">
  <CalloutDescription>
    Click here to view the latest version of [Flexible Classroom](https://search.maven.org/search?q=io.github.agora-apaas).
  </CalloutDescription>
</CalloutContainer>

1. In the Application `onCreate` method, initialize the following:

   ```kotlin
   AgoraSDKInitUtils.initSDK(this)
   ```

2. Call [AgoraOnlineClassroomSDK.launch](/en/api-reference/api-ref/flexible-classroom/classroom-sdk#launch) to start the class. The parameters of `AgoraOnlineClassroomSDK` and `AgoraClassroomSDK` are the same. Refer to the following sample code:

   ```kotlin
   // Before starting the classroom, you need to dynamically apply for `Manifest.permission.RECORD_AUDIO` and `Manifest.permission.CAMERA` permissions
   fun startClassRoom() {
       val appId = "" // Your app ID
       val rtmToken = "" // Your signaling Token
       val userName = "Tom"   	 // Your user name
       val roomName = "MyRoom"  // Your room name
       val roomType = RoomType.SMALL_CLASS.value                     // Class type: 4: Small classes
       val roleType = AgoraEduRoleType.AgoraEduRoleTypeStudent.value // The role only supports 2: Student role
       val roomUuid = HashUtil.md5(roomName).plus(roomType).lowercase()
       val userUuid = HashUtil.md5(userName).plus(roleType).lowercase()
       val roomRegion = AgoraEduRegion.cn  // Area
       val duration = 1800L                // Class duration

       val config = AgoraEduLaunchConfig(
           userName,
           userUuid,
           roomName,
           roomUuid,
           roleType,
           roomType,
           rtmToken,
           null,
           duration
       )

       config.appId = appId
       config.region = roomRegion
       // Set large window video area parameters (large stream)
       config.videoEncoderConfig = EduContextVideoEncoderConfig(
           FcrStreamParameters.HeightStream.width,
           FcrStreamParameters.HeightStream.height,
           FcrStreamParameters.HeightStream.frameRate,
           FcrStreamParameters.HeightStream.bitRate
       )

       AgoraOnlineClassroomSDK.setConfig(AgoraOnlineClassSdkConfig(appId))
       AgoraOnlineClassroomSDK.launch(this, config, AgoraEduLaunchCallback { event ->
           Log.e("agora", ":launch-class status:" + event.name)
       })
   }
   ```

3. To prevent code obfuscation, add the following in the `/Gradle Scripts/proguard-rules.pro` file:

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

<CalloutContainer type="info">
  <CalloutDescription>
    Cloud Classroom does not support dark mode yet.
  </CalloutDescription>
</CalloutContainer>

## Integration considerations

#### Third-party libraries

No matter which method you choose, the third-party libraries Flexible Classroom uses may conflict with the third-party libraries on which your project depends. You can use `exclude` to resolve this conflict or change the version that your project depends on.

    
  
      
  
      
  
      
  


## Platform-specific versions
- [Android](/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom/android.md)
- [iOS](/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom/ios.md)
- [Web](/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom/web.md)
- [Electron](/en/realtime-media/flexible-classroom/build/integrate-the-sdks/integrate-flexible-classroom/electron.md)
