通過閱讀本文,您可以了解Android端推流SDK的集成方法。
環境要求
類別 | 說明 |
開發工具 | 推薦使用Android Studio。 |
Android版本 | 支持Android 5.0及以上版本。 |
步驟一:集成SDK
Maven集成(推薦)
修改項目的build.gradle文件,添加Maven倉庫地址。
maven { url "https://maven.aliyun.com/nexus/content/repositories/releases" }
修改App的build.gradle文件,在
dependencies
節點中添加SDK依賴。本文中引入的SDK版本號僅供參考,獲取最新的版本請參見SDK選擇與下載。
//以下SDK請根據自己的業務需要,選擇一種接入即可 //1.基礎版推流SDK(不支持連麥) implementation 'com.alivc.pusher:AlivcLivePusher:6.9.0' //2.互動版推流SDK(支持連麥) implementation 'com.alivc.pusher:AlivcLivePusher_Interactive:6.9.0'
修改App的build.gradle文件,添加App對應的CPU架構。
defaultConfig { ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8a" } }
手動集成
下載并解壓推流SDK。
復制SDK文件*.aar到App模塊下的libs文件夾。
修改項目的build.gradle文件,在
allprojects
的repositories
節點中增加flatDir
配置。flatDir { dirs 'libs' }
修改App的build.gradle文件,在
dependencies
節點中增加aar的引用。dependencies { implementation fileTree(dir: 'libs', include: ['*.aar']) }
步驟二:配置License授權
推流SDK升級到4.4.2及以后版本,接入一體化License服務,您需要接入License。
步驟三:配置App權限
修改App的src/main/AndroidManifest.xml文件,配置App權限。
<!-- 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" />
步驟四:配置混淆規則
修改App的proguard-rules.pro文件,添加混淆規則。
-keep class org.webrtc.** { *; }
-keep class com.alivc.** { *; }
-keep class com.aliyun.** { *; }
-keep class com.cicada.** { *; }
相關文檔
文檔內容是否對您有幫助?