This topic describes how to integrate the Push SDK for Android.
Prerequisites
Category | Description |
Development tool | Use Android Studio. |
Android version | Supports Android 5.0 and later. |
Step 1: Integrate the SDK
Maven integration (Recommended)
Modify the build.gradle file of your project and add the Maven repository address.
maven { url "https://maven.aliyun.com/nexus/content/repositories/releases" }Modify the build.gradle file of your app and add the SDK dependency to the
dependenciesnode.//Push SDK for Basic Edition implementation 'com.alivc.pusher:AlivcLivePusher:x.y.z'Notex.y.zrepresents the version number of the Push SDK. Replace this placeholder with the latest version number from the SDK Downloads page, such as 7.4.0.The Push SDK cannot be integrated with the Player SDK (AliyunPlayer). To integrate both the Push SDK and the Player SDK, use the All-in-One Media SDK. For more information, see Scenarios and Integration of the All-in-One Media SDK.
Modify the build.gradle file of your app to add the required CPU architectures.
defaultConfig { ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8a" } }
Manual integration
Download and decompress the Push SDK.
Copy the *.aar file of the SDK to the libs folder of your app module.
Modify the build.gradle file of your project and add the
flatDirconfiguration to therepositoriesnode inallprojects.flatDir { dirs 'libs' }Modify the build.gradle file of your app and add the AAR dependency to the
dependenciesnode.dependencies { implementation fileTree(dir: 'libs', include the following: ['*.aar']) }
Step 2: Configure the license
For more information, see License Integration Guide.
Step 3: Configure app permissions
Modify the src/main/AndroidManifest.xml file of your app to configure the required permissions.
<!-- Required for network features. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Required to check the network connection state. -->
<!-- This permission does not require user consent at runtime but must be declared in the manifest. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Required to record audio. You must declare and request this permission at runtime. -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Required to access the 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" />
<!-- Required only if your app communicates with paired Bluetooth devices. -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Required by the demo to access 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" />
<!-- Access audio files -->
<uses-permission
android:name="android.permission.READ_MEDIA_AUDIO"
android:minSdkVersion="33" />
<!-- Access video files -->
<uses-permission
android:name="android.permission.READ_MEDIA_VIDEO"
android:minSdkVersion="33" />
<!-- Required by the demo for screen recording and streaming. -->
<!-- Required to create background tasks. Not required by the SDK. -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- Required to create system overlay windows. -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- Required by the demo for the mute feature. -->
<!-- If this permission is not declared, the stream is not automatically muted during a phone call. -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />Step 4: Configure obfuscation rules
Modify the proguard-rules.pro file of your app to add the required obfuscation rules.
-keep class org.webrtc.** { *; }
-keep class com.alivc.** { *; }
-keep class com.aliyun.** { *; }
-keep class com.cicada.** { *; }Usage notes
For detailed API descriptions, see the Basic Edition API Reference.
For sample code that shows how to use the APIs, see Features.