preface

Recently, an exception “Protocol Not found” was reported when ijkPlayer was used to play the streaming media video using HTTPS in the project. After checking the Issues of the project, it was found that ijkPlayer does not support HTTPS by default, but the official compilation script has been provided. You’ll need to manually compile the integration yourself, and here’s how you did it, along with some of the potholes you encountered.

Compile environment

  • OS: 20.04 LTS still
Any distribution is fine, as long as the required software and dependencies are installed belowCopy the code
  • NDK: r10e
High ijkplayer officially designated version, version should also can compile, have to try, download address: https://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zipCopy the code
  • The SDK: 30.0.5
Versions in 23+ should be okCopy the code
  • AndroidStudio: 4.1.1
All versions in 2.1.3+ are acceptableCopy the code
  • Yasm: 1.3.0
Sudo apt install Yasm sudo apt install Yasm sudo apt install YasmCopy the code
  • Make: 2

  • GCC: 9.3.0

  • G + + : 9.3.0

Sudo apt install build-essential make GCC g++ sudo apt install build-essentialCopy the code
  • Git: 2.25.1
sudo apt install git
Copy the code

Begin to compile

1. Configure environment variables

Edit ~/.bash_profile or ~/.profile to add the following environment variables

export ANDROID_SDK=<your sdk path>
export ANDROID_NDK=<your ndk path>
export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_NDK
Copy the code

2. Download the code

Download ijkPlayer main project

Git clone https://github.com/Bilibili/ijkplayer.git ijkplayer CD ijkplayer git checkout - B latest k0.8.8Copy the code

Initializing the project (ffMPEG, OpenSSL conditional better configure the proxy, otherwise it will be slow)

Sh # Used to support Https./init-android-openssl.shCopy the code

Change the type of compilation, the default is compact version, the full version supports more formats, but the corresponding volume is larger, according to their own needs to choose

CD config rm module.sh ln -s module-default.sh modul. sh # complete ln -s module-lite.sh modul. sh # compact ln -s Module-lite-hevc. sh module.sh # Contains a lite version of hevcCopy the code

Disabled Linux – perf (used prompts, behind the compiler complains “. / libavutil/timer. H: : bind the fatal error: Linux/perf_event. H: No to the file or directory “)

# Add the following code at the end of the file: export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf" export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-bzlib"Copy the code

Begin to compile

CD android/ contrib. /compile-openssl.sh clean # Compile openssl. /compile-openssl.sh all./compile-ffmpeg.sh clean # compile FFmpeg ./compile-ffmpeg.sh all cd .. # compile ijkplayer ontology./compile-ijk.sh allCopy the code

Run ijkplayer – example

1. Upgrade gradle version (new version AndroidStudio must want to upgrade, or you will quote: “gradle sync failed: Unsupported method: SyncIssue. GetMultiLineMessage ()”)

Modify android/ijkplayer/build: gradle file classpath 'com. Android. View the build: gradle: 4.4.1' Modify android/ijkplayer gradle/wrapper/gradle - wrapper. The properties files distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zipCopy the code

2. Add flavor Dimension (new gradle requires each flavor to have a Dimension)

Modify android/ijkplayer/ijkplayer - example/build: gradle file flavorDimensions "platform" productFlavors {all32 {dimension "platform" minSdkVersion 9 } all64 { dimension "platform" minSdkVersion 21 } }Copy the code

3. Add Google () depend on the warehouse (not adding complains “Could not find com. Android. View the build: aapt2:4.4.1-6503028”)

Modify android/ijkplayer/build: gradle file buildscript {repositories {Google add Google () () / / rely on warehouse jcenter ()}} allprojects { Repositories {Google () // Add Google () repository jCenter ()}}Copy the code

At this point, AndroidStudio should be able to compile and run ijkplayer-example smoothly, and you can connect it to your phone for testing

It should be noted that you need to check whether the CPU architecture of your phone is 32-bit or 64-bit, and switch to variantCopy the code

Compiled project address:

Github.com/U2tzJTNE/ij…

Finally, attached is a screenshot of the demo running successfully