Compile the demo

更新时间:
复制 MD 格式

The Flutter Push SDK is a stream ingest tool built on the native layer of the Android and iOS Push SDKs. This topic describes how to compile the demo.

Download the demo

For the latest demo source code and installation package, see SDK download.

Compile the demo

Environment requirements

Category

Requirement

Flutter version

Version 2.5.0 or later, but earlier than 3.0.0. Version 2.8.0 is recommended.

Dart version

Version 2.12.0 or later, but earlier than 3.0.0.

System Version

  • Android 5.0 or later.

  • iOS 10.0 or later.

CPU architecture

armeabi-v7a or arm64-v8a.

Development tools

Use Android Studio or Visual Studio Code.

Compilation

IDE method

Android Studio

  1. Open the project:

    Open Android Studio, click Open, select the flutter_livepush_plugin project, and open the example folder.

  2. Install dependencies:

    In Android Studio, open the pubspec.yaml file and click the Pub Get button in the upper-right corner to install dependencies.

  3. Set up a device:

    Make sure an Android physical device is connected.

  4. Run the app:

    Click the green run button (Run) in the toolbar and select your target device to launch the app.

Visual Studio Code

  1. Open the project:

    Launch Visual Studio Code. Choose File -> Open Folder, select the flutter_livepush_plugin project, and open the example folder.

  2. Install dependencies:

    In this folder, open a command line and run the following command to install dependencies.

    flutter pub get

  3. Set up a device:

    Make sure an Android or iOS physical device is connected. Use the device selector in the bottom-left corner of VS Code to choose your target device.

  4. Run the app:

    Press F5 or click the Run and Debug icon in the activity bar on the left, select the Flutter configuration, and start a debug session.

Xcode (iOS)

  1. Open the project:

    Select the flutter_livepush_plugin project and open the ios folder inside the example directory.

  2. Install CocoaPods dependencies:

    In the ios folder inside the example directory, open a command line and run the following command.

    pod install

  3. Configure signing:

    In Xcode, select the Runner project, go to the Signing & Capabilities tab, and configure a valid developer account and signing certificate.

  4. Run the app:

    Click the run button (▶️) in the Xcode toolbar and select your target device to launch the app.

Command-line method

Go to the example directory (flutter_livepush_plugin > example) and open a command line.

  1. Install dependencies.

    flutter pub get

  2. Compile the project.

    Android

    Important

    Before compiling the Android project, make sure you have installed the Android SDK and Gradle.

    • Run the app:

      Run the following commands to launch the app.

      # Run the debug build
      flutter run --debug
      # Run the release build
      flutter run --release

    • Package an APK file:

      Run the following command to generate an APK file.

      flutter build apk
      Note

      The APK file is located at build/app/outputs/flutter-apk/app-release.apk.

    iOS

    Important

    Before compiling the iOS project, make sure you have installed Xcode and CocoaPods.

    First, initialize CocoaPods dependencies:

    cd ios && pod install && cd ..
    • Run the app:

      Run the following commands to launch the app.

      # Run the debug build
      flutter run --debug
      # Run the release build
      flutter run --release

    • Package an IPA file:

      Run the following command to generate an IPA file.

      flutter build ipa
      Note

      The IPA file is located at build/ios/ipa/Runner.ipa.

FAQ

Compilation issue: pod install fails on iOS

When using Dart version 3.0 or later, running pod install on iOS produces the following error:

[!] CocoaPods could not find compatible versions for pod "Flutter":
In Podfile:
Flutter (from `Flutter`)
url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) was resolved to 0.0.1, which depends on
Flutter
Specs satisfying the `Flutter (from `Flutter`), Flutter` dependency were found, but they required a higher minimum deployment target.

Solution: In the Podfile in the example folder, change the platform :ios, '' value to 12.0.

Compilation issue: CocoaPods and profile environment mismatch

If Xcode fails to run the app and displays the error “The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.”

Perform the following steps:

  1. Delete the Pods folder.

  2. Delete Podfile.lock.

  3. Run pod install --repo-update.

  4. Quit Xcode and reopen the project to compile it.

Compilation issue: Launcher file error (“Type 'UIApplication' does not conform to protocol 'Launcher'”)

If you encounter the following error during compilation: “Type 'UIApplication' does not conform to protocol 'Launcher'”.

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Protocol for UIApplication methods relating to launching URLs.
///
/// This protocol exists to allow injecting an alternate implementation for testing.
protocol Launcher {
    /// Returns a Boolean value that indicates whether an app is available to handle a URL scheme.
    func canOpenURL(_ url: URL) -> Bool

    /// Attempts to asynchronously open the resource at the specified URL.
    func open(
        _ url: URL,
        options: [UIApplication.OpenExternalURLOptionsKey: Any],
        completionHandler completion: ((Bool) -> Void)?)
}

/// Launcher is intentionally a direct passthroguh to UIApplication.
extension UIApplication: Launcher {}

Solution: Modify the code as follows.

/// Launcher is intentionally a direct passthroguh to UIApplication.
extension UIApplication: Launcher {
    func open(_ url: URL, options: [OpenExternalURLOptionsKey : Any], completionHandler completion: ((Bool) -> Void)?) {
        self.open(url, options: options, completionHandler: completion)
        }
}

Other compilation issues

Check that your Flutter version meets the environment requirements.

How to obtain an ingest URL

To obtain an ingest URL, see Generate streaming URLs.

Stream ingest fails in the demo

Use self-service troubleshooting to test your ingest URL and verify that it is valid.

How to view information about ingested audio and video streams

Go to Stream management. Under Active streams, you can view and manage ingested audio and video streams.

How to play back a stream

After starting stream ingest, use a player such as ApsaraVideo Player, FFplay, or VLC to test stream pulling. To obtain a playback URL, see Generate streaming URLs.