WebRTC 版本 Release notes
branches
m108
版本
分支
commit
m108
branch-heads/5359
93081d5
操作系统类型
MacOS
1 2 3 4 5 mkdir -p webrtccd webrtcgit clone https: //chromium.googlesource.com /chromium/tools/depot_tools.git
在终端执行命令:
往 ~/.zshrc 文件中添加路径:
1 2 export webrtc_depot_tools =/Users/suntongmian/Documents/workplace/webrtc/depot_toolsexport PATH =$PATH :$webrtc_depot_tools
让修改生效,在终端执行命令:
下载 Android 平台代码
1 2 3 cd webrtcfetch --nohooks webrtc_android
执行过程如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ➜ webrtc fetch --nohooks webrtc_android Running: gclient root Updating depot_tools.. . WARNING: Your metrics.cfg file was invalid or nonexistent. A new one will be created. Running: gclient config --spec 'solutions = [ { "name": "src", "url": "https://webrtc.googlesource.com/src.git", "deps_file": "DEPS", "managed": False, "custom_deps": {}, }, ] target_os = ["android", "unix"] ' Updating depot_tools.. . Running: gclient sync --nohooks --with_branch_heads Updating depot_tools.. . .. .. .. [0:32:15] Still working on: [0:32:15] src/third_party/android_ndk Syncing projects: 100% (243/243), done. Running: git submodule foreach 'git config -f $toplevel/.git/config submodule.$name.ignore all' Running: git config --add remote.origin.fetch '+refs/tags/*:refs/tags/*' Running: git config diff.ignoreSubmodules all
下载指定的 WebRTC 版本
1 2 3 cd webrtcgclient sync -r 93081d5 --force
执行过程如下:
1 2 3 4 5 6 7 8 9 ➜ webrtc gclient sync -r 93081d5 --force Updating depot_tools... Syncing projects: 100% (242/242) , done. ...... Hook 'download_from_google_storage --directory --recursive --num_threads=10 --no_auth --quiet --bucket chromium-webrtc-resources src/resources' took 367.89 secs Hook 'vpython3 src/testing/generate_location_tags.py --out src/testing/location_tags.json' took 36.50 secs Running hooks: 100% (29/29) , done.
创建 Android 工程
生成 Android 平台的 Android Studio 工程,在终端执行命令:
1 2 3 4 5 cd webrtccd srcgn gen out /android --args ='target_os="android" target_cpu="arm64" is_debug=true'
执行结果:
1 2 3 4 5 6 7 ERROR Unresolved dependencies. //examples/androidapp /third_party/autobanh :autobanh_java__header (//build /toolchain/android :android_clang_arm64 ) needs //third_party/ijar :ijar (//build /toolchain/mac :clang_x64 ) //third_party/accessibility _test_framework: accessibility_test_framework_java__header(//build /toolchain/android :android_clang_arm64 ) needs //third_party/ijar :ijar (//build /toolchain/mac :clang_x64 ) ......
在 macOS 系统上生成 WebRTC Android 工程报错了。如何解决?
Supported to compile webRTC for Android on a Mac? 提到“WebRTC android development is not supported on mac”。官方解释不支持在 Mac 设备上编译 Android 平台的 WebRTC。
如果要在 Mac 设备上编译 Android 平台的 WebRTC 工程,该怎么办?
根据错误提示“ERROR Unresolved dependencies. needs //third_party/ijar:ijar(//build/toolchain/mac:clang_x64)”,查看 webrtc/src/third_party/ijar/BUILD.gn 文件的内容。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ➜ src git:(93081 d594f) cat third_party/ijar/BUILD.gn if (is_linux || is_chromeos) { config("ijar_compiler_flags" ) { if (is_clang) { cflags = [ "-Wno-shadow" , "-Wno-unused-but-set-variable" , ] } } executable("ijar" ) { sources = [ "classfile.cc" , "common.h" , "ijar.cc" , "mapped_file.h" , "mapped_file_unix.cc" , "platform_utils.cc" , "platform_utils.h" , "zip.cc" , "zip.h" , "zlib_client.cc" , "zlib_client.h" , ] deps = [ "//third_party/zlib" ] configs += [ ":ijar_compiler_flags" ] if (is_debug) { configs -= [ "//build/config:debug" ] configs += [ "//build/config:release" ] } } }
将 if (is_linux || is_chromeos) 修改为 if (is_linux || is_chromeos || is_mac)
,让 gn 支持 Mac 设备编译 Android 平台的 WebRTC 工程。
再次在终端执行命令:
1 2 3 4 5 cd webrtccd srcgn gen out /android --args ='target_os="android" target_cpu="arm64" is_debug=true'
执行结果:
1 2 ➜ src git:(93081 d594f) gn gen out /android --args='target_os="android" target_cpu="arm64" is_debug=true' Done. Made 6591 targets from 356 files in 2002 ms
在终端执行命令:
1 autoninja -C out /android -t targets all
启动 Android Studio 工程
1 open -a Android\ Studio ./out /android
参考文献
[1] WebRTC Android development