Android Core SDK Quickstart
This quickstart shows how to use Dyte's Android Core SDK to add live video and audio to your Android applications.
For getting started quickly, you can use our sample code. You can clone and run a sample application from the Android Core SDK GitHub repository.
Objective
You’ll learn how to:
- Install the Dyte SDK
- Initialize the SDK
- Configure a Dyte meeting
- Initialize the Dyte meeting
- And go live with your Dyte meeting
Before Getting Started
Make sure you've read the Getting Started with Dyte topic and completed the steps in the Integrate Dyte section. You must complete the following steps:
- Create a Dyte Developer Account
- Create Presets
- Create a Dyte Meeting
- Add Participant to the meeting
- Install Android Studio
Step 1: Install the SDK
- Install the SDK using maven dependency.
dependencies {
// (other dependencies)
implementation 'io.dyte:core:+'
}
- Add the following permissions to the AndroidManifest.xml file.
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
If you intend to publish your app to the Google Play, you'll need to perform a few additional steps. So if you’re working on release builds and not debug builds, refer to the Release Builds section.
Step 2: Initialize the SDK
The DyteMobileClient
is the main class of the SDK. It is the entry point and
the only class required to initialize Dyte SDK.
val dyteClient = DyteMobileClient();
Step 3: Set the meeting properties
Set the properties in the DyteMeetingInfo
class. You just need to provide the
participant's authToken
.
Name | Description |
---|---|
authToken | After you've created the meeting, add each participant to the meeting using the Add Participant API (The presetName created earlier must be passed in the body of the Add Participant API request) The API response contains the authToken . |
enableAudio | Default setup for audio when user joins in a meeting. |
enableVideo | Default setup for video when user joins in a meeting. |
val meetingInfo = DyteMeetingInfo(
authToken = '<auth_token>',
)
Step 4: Initialize the connection request
To initialize the connection request, call the init()
method obtained on
dyteClient
with the meetingInfo
argument. This will establish the connection
with the Dyte meeting server.
dyteClient.init(meetingInfo)
By registering state observers, you receive callbacks for this action on the
dyteClient
object.
private val meetingEventListener = object : DyteMeetingRoomEventsListener {
override fun onMeetingInitStarted() {
super.onMeetingInitStarted()
}
override fun onMeetingInitCompleted() {
super.onMeetingInitCompleted()
}
override fun onMeetingInitFailed(exception: Exception) {
super.onMeetingInitFailed(exception)
}
}
dyteClient.addMeetingRoomEventsListener(meetingEventListener)
Step 5: Connect to the meeting
Now, you have established the connection with the Dyte meeting server successfully. Next step is to join the room.
Join the room
To join the meeting room, call joinRoom()
method on the dyteClient
instance
as shown below.
dyteClient.joinRoom();
By registering state observers, you receive callbacks for this action on the meeting object.
private var selfEventListener: DyteSelfEventsListener? = object : DyteSelfEventsListener {
override fun onMeetingRoomJoinStarted() {
super.onMeetingRoomJoinStarted()
}
override fun onMeetingRoomJoined() {
super.onMeetingRoomJoined()
}
override fun onMeetingRoomJoinFailed(exception: Exception) {
super.onMeetingRoomJoinFailed(exception)
}
}
dyteClient.addSelfEventsListener(selfEventListener)
Leave the room
Once the meeting is over, you can leave the meeting room.
To leave the meeting room, call leaveRoom()
method on the dyteClient
as
shown below.
dyteClient.leaveRoom();
By registering state observers, you receive callbacks for this action on the meeting object.
private var selfEventListener: DyteSelfEventsListener? = object : DyteSelfEventsListener {
override fun onMeetingRoomLeaveStarted() {
super.onMeetingRoomLeaveStarted()
}
override fun onMeetingRoomLeft() {
super.onMeetingRoomLeft()
}
}
dyteClient.addSelfEventsListener(selfEventListener)
Release Builds
If you intend to publish your app to the Google Play, perform the following steps after installing the SDKs. So if you’re working on release builds and not debug builds, do the following:
For Android release builds
Perform the following steps, for Android release builds:
- Create
/android/app/proguard-rules.pro
file.
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}
# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}
# keep webrtc classes
-keep class org.webrtc.** { *; }
-dontwarn org.chromium.build.BuildHooksAndroid
# keep ktor classes
-keep class io.ktor.** { *; }
- Add the following to your
android/app/build.gradle
to import the proguard configuration.
buildTypes {
release {
...
...
...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}