This topic describes how to integrate Push SDK for Android.

Environment requirements

Item Requirement
Android version Android 5.0 or later.
Android API version API 21 or later.
CPU architecture ARM64 or ARMv7.
Integration tool We recommend that you use Android Studio. To download Android Studio, visit the Android Studio page.

Download the SDK package

Download the latest Push SDK for Android by using the download link provided in the SDK download and release notes topic.

Integrate the SDK

  1. Integrate the SDK by using AAR packages or Maven dependencies.
    • Use AAR packages
      Create a project and copy all the files in the SDK package to the libs folder of your project. Modify the dependencies in the build.gradle file of the main module in your project. Generally, the main module is named app. Then, run the following code to recompile your project:
      implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
      Use AAR packages
      Note If you want to add background music, you must use ApsaraVideo Player SDK, which is encapsulated in the AliyunPlayer.aar package.
    • Use Maven dependencies

      Add the following code to the allprojects block in the build.gradle file:

      
      implementation 'com.alivc.pusher:AlivcLivePusher:4.2.1'
  2. Configure the permissions to use features and access resources.
    Note To use the recording feature and the camera, you must add the related permission configurations to the Info.plist file.
    Add the following code to the AndroidManifest file:
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.REORDER_TASKS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    // Configure the permissions to use the recording feature.
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    // Configure the permissions to use the camera.
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <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" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  3. Add the obfuscation configuration.
    Add the following code to the proguard-rules.pro file:
    -keep class com.alivc.** { *;}
  4. Use the SDK.