Skip to main content

Build ijkplayer with lib-monitor

ResearchAndroidClangNDKijkplayerAbout 2 minAbout 504 words

Environment Setup

  1. prepare the environment as shown above
  2. follow instructions below to get missing parts of NDK
  3. configure variables in ijkplayer/build.sh and lib-monitor/inserter/Makefile according to your setup
  4. click AVD Manager and create a device with the following system image:
Release NameAPI LevelABITarget
Nougat25armeabi-v7aAndroid 7.1.1 (Google APIs)

Get Missing Parts of NDK[1]

Info

We are going to use NDK-r21e.

Version information is in file ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/AndroidVersion.txt.

9.0.9
based on r365631c3
  1. visit the corresponding source at clang-r365631c3 - platform/prebuilts/clang/host/linux-x86 - Git at Googleopen in new window and download tgzopen in new window
  2. extract the downloaded file and merge it with ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64.

Tips

You may want to remove clang.real and clang++.real under ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/.

Build

  1. launch Android Studio, select android/ijkplayer/ and import
  2. install dependencies according to logs from Android Studio
  3. run the following scripts:
bash init-android.sh
bash build.sh

Note

We choose to use NDK-r21e for ffmpeg and NDK-r14b for anything else. There are both c and c++ sources elsewhere. However, the -std=c99 option ( configured in Android.mk ) will cause an error in NDK-r21e ( with newer clang++ ) but simply a warning in NDK-r14b.

Run

  1. click Run selected configuration or press shift + F10 in Android Studio
  2. click Sample in Android Emulator
  3. choose a video from the list and click

Tips

When sliding the video list, the simulator may treat the wheel scroll as a click event, so the safe way is to hold down the mouse and drag.

Info

Sometimes the player would crash. Just try to reopen the video from the list. I’m currently working for a solution.

Debug

ADB

By default, you may find the executable adb at "${HOME}/Android/Sdk/platform-tools/adb". Here are some commonly used adb commands:

./adb devices [-l] # list connected devices (-l for long output)
./adb shell # run remote shell command (interactive shell if no command given)

You can enter interactive shell and cd to /sdcard/ to see whether recorder.cov has been created.

logcat

In Android Studio, click 6: Android Monitor and click logcat tab to view logcat. In addition, you can change the level of logging and use the search box ( for example "lib-monitor" ) to filter logs.

Reference


  1. 史上最优雅的 NDK 加载 pass 方案 - 先知社区open in new window ↩︎