Clone the depot_tools repository:
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Add depot_tools to the front of your PATH (you will probably want to put this in your ~/.bashrc
or ~/.zshrc
). Assuming you cloned depot_tools to /path/to/depot_tools
:
$ export PATH=/path/to/depot_tools:$PATH
Create a working directory, enter it, and run:
$ fetch --nohooks webrtc_android //会在当前执行目录中下载文件到src文件夹
$ gclient sync
# 进入到src目录中
cd src # 执行完后,当前目录应为 /home/webrtc/webrtc_android/src
# 下载 java相关命令和包,以及其他一些必要的软件和包
build/install-build-deps-android.sh # 执行过程中要输入 sudo 密码
(需要在ubuntu英文语言环境下编译)
Generate projects using GN.
Make sure your current working directory is src/ of your workspace. Then run:
gn gen out/Debug --args='target_os="android" target_cpu="arm"'
Compile using:
autoninja -C out/Debug
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
此时需要更新git版本为官网最新版本,重试fetch android
OSError: [Errno 1] Operation not permitted
Error: Command ‘vpython src/build/download_nacl_toolchains.py –mode nacl_core_sdk sync –extract’ returned non-zero exit status 1 in /media/psf/Home/git/demo/webrtc/android
makelink Operation not permitted
Cannot utime: Operation not permitted
…./webrtc_android/src/out/Debug/lib.java/sdk/android/libwebrtc.jar
…/webrtc_android/src/out/Debug/libjingle_peerconnection_so.so
…/webrtc_android/src/out/Debug/lib.unstripped/libjingle_peerconnection_so.so
…/webrtc_android/src/out/Debug/clang_x64/protoc
https://github.com/HackWebRTC/webrtc/tree/hack_webrtc/sdk/android_gradle
该项目组在脚本中配置固定的文件路径导致无法在新版webrtc源码上编译
CMakeLists.txt
${WEBRTC_REPO}/sdk/libs/ffmpeg/lib/Android/${ANDROID_ABI}/libswresample.a
// def newProjectRoot = "$webrtc_repo/sdk/android_gradle"
def newProjectRoot = rootProject.rootDir
sourceSets.main.java.srcDirs = [
"$newProjectRoot/../android/api",
"$newProjectRoot/../android/src/java",
"$newProjectRoot/../../rtc_base/java/src",
"$newProjectRoot/../../modules/audio_device/android/java/src",
"$newProjectRoot/webrtc/src/main/java",
]
androidCompileSdkVersion = 30
配置本地native调试目录:
# the absolute path of WebRTC Android checkout, please use exactly the same commit as this repo.
webrtc_repo=/Users/qianpianpian/git/demo/webrtc/webrtc_android/src
# the relative path of where generated source file is put, relative to `webrtc_repo`.
webrtc_build_dir=out/android_studio
# the relative path of Android sdk jar, relative to `webrtc_repo`.
android_jar=third_party/android_sdk/public/platforms/android-30/android.jar
# the absolute path of Python 2.x executable
py2=/usr/bin/python
# the absolute path of protoc executable, see README about how to create it.
protoc=/Users/qianpianpian/git/demo/webrtc/webrtcOut/protoc
https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/android/index.md
Ubuntu18.04 从头开始编译 Android Native WebRTC
https://github.com/mail2chromium/Compile_WebRTC_Library_For_Android