This topic describes how to integrate the software development kit (SDK) for Android.
Prerequisites
For information about the specific prerequisites for Android, see Limits.
Integrate the SDK
Method 1: Integrate using Maven (Recommended)
Add the Maven repository URL to the build.gradle file in the root directory:
allprojects { repositories { google() jcenter() // Add the Maven URL for RTC. maven { url "http://maven.aliyun.com/nexus/content/groups/public/" } } }Add the following lines to the app/build.gradle file of your project:
dependencies { ... // The RTC SDK dependency implementation 'com.ding.rtc:dingrtc-full:3.0.0' }NoteThe Maven dependency version is for reference only. To obtain the latest Maven dependency, see SDK download.
Add the following code to the app/src/main/AndroidManifest.xml file to obtain the required device permissions.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ding.rtc"> <!-- Network permissions --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Video permissions --> <uses-permission android:name="android.permission.CAMERA" /> <!-- Audio recording permissions --> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- The startBluetoothSco method for Bluetooth uses this permission --> <uses-permission android:name="android.permission.BROADCAST_STICKY"/> <application> <activity android:name="org.webrtc.mozi.JavaScreenCapturer$ScreenCaptureAssistantActivity" android:theme="@android:style/Theme.Translucent" /> </application> </manifest>If your Android project has a targetSdkVersion of 31 or later, you must dynamically request the
android.permission.BLUETOOTH_CONNECTpermission in your code to use Bluetooth features. For more information, see the official Android documentation.Configure code obfuscation.
In the proguard-rules.pro file, add the
-keepclass configuration to prevent the public class names of the Real-Time Communication (RTC) SDK from being obfuscated.-keep class org.webrtc.**{*;} -keep class com.ding.rtc.**{*;}
Method 2: Manual integration
Download and decompress the Android SDK. For the download link, see SDK download.
Copy the DingRtc.aar SDK file to the libs folder in the App module.
Add the following code to the app/src/main/AndroidManifest.xml file to obtain the required device permissions.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ding.rtc"> <!-- Network permissions --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Video permissions --> <uses-permission android:name="android.permission.CAMERA" /> <!-- Audio recording permissions --> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- The startBluetoothSco method for Bluetooth uses this permission --> <uses-permission android:name="android.permission.BROADCAST_STICKY"/> <application> <activity android:name="org.webrtc.mozi.JavaScreenCapturer$ScreenCaptureAssistantActivity" android:theme="@android:style/Theme.Translucent" /> </application> </manifest>If your Android project has a targetSdkVersion of 31 or later, you must dynamically request the
android.permission.BLUETOOTH_CONNECTpermission in your code to use Bluetooth features. For more information, see the official Android documentation.Configure code obfuscation.
In the proguard-rules.pro file, add the
-keepclass configuration to prevent the public class names of the Real-Time Communication (RTC) SDK from being obfuscated.-keep class org.webrtc.**{*;} -keep class com.ding.rtc.**{*;}
What to do next
After you integrate the SDK, you can implement the basic features of Real-Time Communication. For more information, see Implement basic features for Android.