This topic describes how to integrate the Push SDK for Android.
Environment requirements
Item | Description |
Development tool | Android Studio is recommended. |
Android version | Android 5.0 or later is required. |
Step 1: Integrate the SDK
(Recommended) Integrate the SDK using Maven
Add the Maven repository URL to your project's `build.gradle` file.
maven { url "https://maven.aliyun.com/nexus/content/repositories/releases" }Add the SDK dependency to the
dependenciesnode in your app's `build.gradle` file.// Basic Edition of the Push SDK implementation 'com.alivc.pusher:AlivcLivePusher:x.y.z'Notex.y.zis the version number of the Push SDK. Replace `x.y.z` with the latest version number from SDK downloads, such as 7.4.0.The Push SDK and the Player SDK (AliyunPlayer) cannot be integrated simultaneously. To integrate both SDKs, you must use the ApsaraVideo MediaBox SDK. For more information, see Scenarios and Integrate the ApsaraVideo MediaBox SDK.
Add the CPU architectures for your app to the app's `build.gradle` file.
defaultConfig { ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8a" } }
Manually integrate the SDK
Download and decompress the Push SDK.
Copy the `*.aar` file from the SDK to the `libs` folder of your app module.
In your project's `build.gradle` file, add the
flatDirconfiguration to therepositoriesnode of theallprojectsblock.flatDir { dirs 'libs' }Add a reference to the AAR file in the
dependenciesnode of your app's `build.gradle` file.dependencies { implementation fileTree(dir: 'libs', include the following: ['*.aar']) }
Step 2: Configure the license
For instructions, see the License Integration Guide.
Step 3: Configure app permissions
Configure the required permissions in your app's `src/main/AndroidManifest.xml` file.
<!-- Used for network features -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- To check the network connection state of the device, you'll need to add the ACCESS_NETWORK_STATE permission. -->
<!-- This permission does not require user consent at runtime, but needs to be declared in the app's AndroidManifest.xml. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- If the app needs to record audio, you need to declare the RECORD_AUDIO permission and request this permission at runtime -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- The application needs to access the device's camera -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<!-- Needed only if your app communicates with already-paired Bluetooth devices. -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Only used by Demo for accessing storage files -->
<!-- Storage permissions -->
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<!-- Access image files -->
<uses-permission
android:name="android.permission.READ_MEDIA_IMAGES"
android:minSdkVersion="33" />
<!-- Write audio files -->
<uses-permission
android:name="android.permission.READ_MEDIA_AUDIO"
android:minSdkVersion="33" />
<!-- Write video files -->
<uses-permission
android:name="android.permission.READ_MEDIA_VIDEO"
android:minSdkVersion="33" />
<!-- Only used by Demo for screen recording and streaming -->
<!-- Used for creating background tasks, not required by SDK -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- Requesting permission to create system overlay windows -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- Only used by Demo for muting -->
<!-- If this permission is not declared, the feature of automatically muting the stream during a phone call will not work -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />Step 4: Configure obfuscation rules
Add the obfuscation rules to your app's `proguard-rules.pro` file.
-keep class org.webrtc.** { *; }
-keep class com.alivc.** { *; }
-keep class com.aliyun.** { *; }
-keep class com.cicada.** { *; }Usage notes
For detailed API information, see the API reference for the Basic Edition.
For sample code on how to use the API, see Use features.