Android audio and video development practice series-05-Download WebRTC source code from the official website and compile and release the aar package to GitHubPackages

foreword

Presumably students who have experience in compiling the official source code of WebRTC, because they cannot directly connect to the external network, in fact, most of the time is not spent on compiling, but on downloading the source code of WebRTC. As the saying goes, everything is difficult at the beginning. After stepping on an unknown number of pitfalls, this article came into being, hoping to help you.

Reminder: If you do not have a stable scientific Internet access tool, it is recommended not to try to download the source code from the official website to compile WebRTC, because some programs in depot_tools must be connected to the external network to download locally. If you cannot connect to the external network, there will be many even if you use domestic mirror Errors are reported, and these errors will be mentioned in the following chapters on solutions to common errors.

Preparation

System Requirements

The official recommendation recommends using the following system versions for compilation:

  • Ubuntu 14.04 LTS (trusty with EoL April 2022)
  • Ubuntu 16.04 LTS (xenial with EoL April 2024)
  • Ubuntu 18.04 LTS (bionic with EoL April 2028)
  • Ubuntu 20.04 LTS (focal with Eol April 2030)
  • Ubuntu 19.04 (disco)
  • Ubuntu 19.10 (eoan)

How do you know? There is a script ./build/install-build-deps.sh in the source code. Execute it. If your system version does not match, the following error will be reported.

ERROR: The only supported distros are
        Ubuntu 14.04 LTS (trusty with EoL April 2022)
        Ubuntu 16.04 LTS (xenial with EoL April 2024)
        Ubuntu 18.04 LTS (bionic with EoL April 2028)
        Ubuntu 20.04 LTS (focal with Eol April 2030)
        Ubuntu 19.04 (disco)
        Ubuntu 19.10 (eoan)

Disk: It is recommended to prepare 20GB disk space, you can figure it out.
image.png
Memory: At least 8GB is recommended. When I think of compiling Android, 32G is exhausted.

Digression: No matter what source code is compiled, it is recommended to keep it consistent with the officially recommended compilation environment, because there are many inexplicable problems, which are actually caused by the compilation environment, and it is not worth spending too much time stepping on these pitfalls.

Warm reminder, the tutorial for downloading WebRTC source code and compiling is mainly from: https://webrtc.github.io/webrtc-org/ , the author uses Ubuntu 20.04.5 LTS 64 system, and configures a domestically produced 2T PCIE 3.0 SSD, computer memory is 32G, CPU is AMD 5900X. Before starting, please reconfirm whether you have prepared a stable science network Internet tool, if not, please do not try it lightly.

The important thing is to say it again. It is strongly recommended to use the officially recommended Ubuntu version to compile the source code. The same is true for Android. A consistent compilation environment often gets twice the result with half the effort, allowing you to avoid more detours.
As for Windows, I don't have the energy to try it for the time being. I searched the Internet and found that many big guys have already published tutorials. Here I recommend the second WebRTC note of the grass climber: compilation (updated in March 2021)

What is depot_tools

The official introduction is as follows:
Chromium and Chromium OS use a package of scripts called depot_tools to manage checkouts and code reviews.
The depot_tools package includes gclient, gcl, git-cl, repo, and others.
View the updated depot_tools set-up documentation in the depot_tools tutorial . Then continue with the tutorial or see the depot_tools documentation for usage. These same docs are also available as man pages.
See also How-To: Using depot_tools
Machine Translation:
Chromium and Chromium OS use a script package called depot_tools to manage checkouts and code reviews.
The depot_tools package includes gclient, gcl, git-cl, repo, etc.
Check out the updated depot_tools setup documentation in the depot_tools tutorial. Then continue with this tutorial or check out the depot_tools documentation for usage. These same documents are also available as man pages.
See also how-to: Using depot_tools

Extended reading:
freeabc talks about the build tool depot_tools today , and has a basic understanding of depot_tools. The principle and implementation of depot_tools
are too unfeeling , and understanding the principle of depot_tools will help you solve the error reporting problems encountered independently.

Download depot_tools

The first step, of course, is to install depot_tools. Many tutorials take this step in one stroke, but in fact, this seemingly simple step contains many pitfalls, which will be mentioned later.

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

It's very simple, just use the Git tool Clone, you don't have Git yet.

The author created a new webrtc directory here, as follows:

insert image description here

Open the command line terminal and execute the following command:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
picture.png
Do you think it will go well? Not long after, the overtime gift package will be delivered immediately.
You might say, doesn't depot_tools.git also have a domestic mirror? Why not? You're right, let's arrange it right away.

# 声网Agora WebRTC团队提供的 WebRTC 镜像源
git clone https://webrtc.bj2.agoralab.co/webrtc-mirror/depot_tools.git depot_tools_agoralab

# Qualcomm Innovation Center团队提供的 WebRTC 镜像源
git clone https://source.codeaurora.org/quic/lc/chromium/tools/depot_tools.git depot_tools_quic -b chromium.org/main

After testing, the WebRTC mirror source provided by Agora WebRTC team is the fastest.
picture.png
The WebRTC mirror source provided by the Qualcomm Innovation Center team is not bad, but it is not the master branch by default, and the branch needs to be specified by -b.
picture.png

注意:source.codeaurora.org 已经迁移到git.codelinaro.org
Note: Qualcomm Innovation Center Inc. maintained repositories have migrated to git.codelinaro.org. QUIC repositories on this site will not receive any updates after March 31, 2022, and will be deleted on March 31, 2023. If your project depends on these repositories, please adjust your tooling configuration to use the new, up-to-date project location.

The depot_tools tool has been downloaded, but things are far from smooth, because some tools need to be connected to the external network to download, and I will tell you when I use it later.

Install depot_tools

To install depot_tools, set the path of the executable program to the environment variable. First, set the current directory as the workspace.

export WORKSPACE=`pwd`

Next, set the environment variables of the depot_tools directory. cipd is also modified to executable permissions.

#WORKSPACE变量是前面设置的,如果你有多个depot_tools源,注意修改为实际你要用的depot_tools路径
chmod +x $WORKSPACE/depot_tools/cipd
export PATH=$PATH:$WORKSPACE/depot_tools

Note that the environment variables set by executing the export command on the current command line are temporary (because I want to try to use different depot_tools sources, it is more convenient to use temporary environment variables).

If you want to set a permanent environment variable (recommended), it is recommended to add the environment variable to the ~/.bashrc file. Specifically, add the following command to ~/.bashrc, and input source ~/.bashrc to reload bash. The /path/to/ needs to be replaced by the path where depot_tools is located.

export PATH=/path/to/depot_tools:$PATH

The screenshot of the directory is as follows:
picture.pngFor more knowledge about environment variable settings, interested students can search and learn by themselves.

Execute gclinet from the command line, if no error is reported, the command line cannot be found, indicating that the environment variable configuration is successful.
picture.pngOr execute the which gclient command to find the path.
picture.png

Configure Git

This step is generally set by everyone, mainly to set the global account information of Git.

$ git config --global user.name "XXX"
$ git config --global user.email "[email protected]"
$ git config --global core.autocrlf false
$ git config --global core.filemode false
$ # and for fun!
$ git config --global color.ui true

Download synchronous WebRTC source code

Use domestic WebRTC mirror (not recommended)

In fact, due to the existence of the wall, the first time I tried to compile the WebRTC source code was to follow the WebRTC mirror tutorial of the Agora WebRTC team. The tutorial comes from: https://webrtc.org.cn/mirror/ . In order to tell everyone the pits that have been stepped on as much as possible, the author follows this tutorial to go through them again so that everyone can skip these pits. Of course, the steps of synchronizing Google official warehouse and Github WebRTC image source code will also be taught step by step.

The command line used:

export WORKSPACE=`pwd`

cd $WORKSPACE

rm -rf depot_tools_agoralab && git clone https://webrtc.bj2.agoralab.co/webrtc-mirror/depot_tools.git depot_tools_agoralab

chmod +x $WORKSPACE/depot_tools_agoralab/cipd

export PATH=$PATH:$WORKSPACE/depot_tools_agoralab

which gclient

mkdir -p $WORKSPACE/webrtc-agoralab && cd $WORKSPACE/webrtc-agoralab

solutions = [
  { "name"        : "src",
    "url"         : "https://webrtc.bj2.agoralab.co/webrtc-mirror/src.git@65e8d9facab05de13634d777702b2c93288f8849",
    "deps_file"   : "DEPS",
    "managed"     : False,
    "safesync_url": "",
    "custom_deps": {
    },
  },
]
target_os = ["android"]


Screenshot of the process:
image.pngObviously using a domestic mirror, but still need to connect to a foreign website, then an error will be reported!

curl: (28) Failed to connect to chrome-infra-packages.appspot.com port 443: 连接超时
curl: (28) Failed to connect to chrome-infra-packages.appspot.com port 443: 连接超时
/media/xiangang/Repository/webrtc/depot_tools_agoralab/bootstrap_python3: 行 32: bootstrap-3.8.0.chromium.8_bin/python3/bin/python3: 没有那个文件或目录
/media/xiangang/Repository/webrtc/depot_tools_agoralab/gclient: 第 32 行: exec: python:未找到

In the end, you still have to use scientific online tools (if I had one, I would have used it a long time ago, let me tell you). Can I not use it? In theory it should be possible. For example, after the author downloads, upload the full version of depot_tools to Github for everyone to download and use, isn't that all right? The author searched for depot_tools on Github, and found that they were uploaded directly by fork or clone, and did not include bootstrap-3.8.0.chromium.8_bin. It may be of little significance to do so, because when actually synchronizing the WebRTC source code, scientific Internet tools must be used, so it is better to use scientific Internet tools from beginning to end to avoid unexpected pitfalls.

Then open the scientific Internet tool and open the network agent.
image.pngNote that you need to execute curl cip.cc first to check whether the current terminal is valid. If the ip still shows domestic, you need to restart a new terminal.
image.pngFor the demonstration, the author used the domestic depot_tools image, so the environment variable of depot_tools is temporary, so the new terminal opened needs to reconfigure the environment variable. After a short operation, you can see that curl cip.cc has changed to a foreign IP.

gclient: line 32: exec: python: problem not found. Solution: Execute export GCLIENT_PY3=1 on the command line.

At this time, you can re-execute: gclient sync. But in fact, the proxy network may not be very stable. It is recommended to write a script, execute the gclient sync command in a loop, and exit the execution after a period of time after the synchronization is completed.

#!/bin/bash
gclient sync
while [ $? -ne 0 ]
do
echo "======gclient sync failed ,gclient sync again======"
sleep 3
gclient sync
done

use:

touch sync.sh  # 1. 创建 sync.sh 文件
vim sync.sh # 2. 复制上面的脚本内容到 sync.sh 里面,这里你可以使用你自己喜欢的方法打开并修改文件,比如 vscode
chmod a+x sync.sh #3. 修改权限
./sync.sh # 4. 运行脚本,万事大吉

After a period of unremitting efforts, the source code can be downloaded and synchronized normally (actually it may not be so smooth, I wish you good luck). However, the author strongly does not recommend the use of domestic mirroring. It is okay if there is no problem, but it will be a waste of time if there is a problem. Moreover, you don't even know whether the domestic mirror is updated synchronously, and which version it is updated to.

Use Google's official WebRTC source code (recommended)

Prerequisite: Open the scientific Internet tool and open the network proxy.

After it is enabled, execute the command curl cip.cc to check whether the terminal is in the proxy state. Why not ping google, because ping is an ICMP message, and the agent does not forward it, so you cannot use ping to detect whether the network agent of the middle terminal is successful, remember to remember.
Extended reading: Several ways to program the big K Linux to let the terminal use the proxy
picture.png . Note that if the command curl cip.cc still displays the domestic ip, you can open a new command line terminal and operate again.

Downloading and installing depot_tools is not much to say, it is also obtained from Google's official website, and the environment variables are set.

Create a directory called webrtc-checkout at the same level as the depot_tools directory.
picture.png
Enter the webrtc-checkout directory to execute, execute the following command

#手动创建目录则跳过,直接在对应目录打开命令行终端
mkdir webrtc-checkout && cd webrtc-checkout
#fetch是用来初始化项目配置的工具,一般会在第一次拉取项目时用到,这里配置获取webrtc android平台的代码
fetch --nohooks webrtc_android
#此命令主要负责拉取项目代码、执行代码hook等操作,是gclient最重要的功能。
gclient sync

#其他平台的
linux : fetch --nohooks webrtc
android: fetch --nohooks webrtc_android
ios: fetch --nohooks webrtc_ios

Again, if you don't have a stable scientific Internet tool, it is recommended not to toss yourself. Otherwise, it will be like the following, take one step, one wrong step, one wrong step, one wrong step. picture.png
You may be prompted to update depot_tools, just select N.
To disable automatic updates, an environment variable can be set: DEPOT_TOOLS_UPDATE=0.

OK to update it to https://chromium.googlesource.com/chromium/tools/depot_tools.git ? [Y/n] n

The next step is to wait for the source code synchronization to complete. If it fails, you can try to execute it a few more times, and it is generally smooth.

Using the WebRTC mirror on Github

The image comes from: https://github.com/ibaoger/webrtc.git
Create a new webrtc-github directory, enter the directory and create a new .gclient file, write the content as follows:

solutions = [
  { "name"        : 'src',
    "url"         : 'https://github.com/ibaoger/webrtc.git',
    "deps_file"   : 'DEPS',
    "managed"     : True,
    "custom_deps" : {
    },
    "custom_vars": {},
  },
]
target_os = [ 'android' ]

Open the command line terminal to execute gclient sync. The complete execution process is as follows:

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github$ gclient sync

________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://github.com/ibaoger/webrtc.git /media/xiangang/Repository/webrtc/webrtc-github/_gclient_src_rubntize' in '/media/xiangang/Repository/webrtc/webrtc-github'
Cloning into '/media/xiangang/Repository/webrtc/webrtc-github/_gclient_src_rubntize'...
remote: Enumerating objects: 425721, done.
remote: Counting objects: 100% (2220/2220), done.
remote: Compressing objects: 100% (901/901), done.
Receiving objects:   9% (41042/425721), 18.85 MiB | 43                                                                                                                                                                                                                                                                                                                                                                Receiving objects:   9% (41042/425721), 19.80 MiB | 65                                                                                                                                                     Receiving objects:   9% (41044/425721), 22.65 MiB | 54                                                                                                                                                                                                                                                                                                                                                                Receiving objects:   9% (41044/425721), 23.39 MiB | 49                                                                                                                                                                                                                                                                                                                                                                Receiving objects:   9% (41045/425721), 24.10 MiB | 46                                                                                                                                                     remote: Total 425721 (delta 1361), reused 2092 (delta 1307), pack-reused 423501
Receiving objects: 100% (425721/425721), 262.00 MiB | 52.00 KiB/s, done.
Resolving deltas: 100% (345232/345232), done.
Syncing projects:   0% ( 1/246) src
[1:25:38] Still working on:
[1:25:38]   src/base
[1:25:38]   src/build
[1:25:38]   src/buildtools
[1:25:38]   src/examples/androidtests/third_party/gradle
[1:25:38]   src/testing
[1:25:38]   src/third_party
[1:25:38]   src/tools

...省略

Syncing projects:   3% ( 8/246) src/examples/androidtests/third_party/gradle
src/buildtools (ERROR)
----------------------------------------
[1:24:37] Started.
[1:24:37] 

________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src/buildtools /media/xiangang/Repository/webrtc/webrtc-github/src/_gclient_buildtools_luvh_dxs' in '/media/xiangang/Repository/webrtc/webrtc-github'

[1:24:37] Cloning into '/media/xiangang/Repository/webrtc/webrtc-github/src/_gclient_buildtools_luvh_dxs'...
[1:26:48] fatal: unable to access 'https://chromium.googlesource.com/chromium/src/buildtools/': Failed to connect to chromium.googlesource.com port 443: Connection timed out
[1:26:50] 
________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src/buildtools /media/xiangang/Repository/webrtc/webrtc-github/src/_gclient_buildtools_luvh_dxs' in '/media/xiangang/Repository/webrtc/webrtc-github' attempt 2 / 2

[1:26:50] Cloning into '/media/xiangang/Repository/webrtc/webrtc-github/src/_gclient_buildtools_luvh_dxs'...
[1:29:01] fatal: unable to access 'https://chromium.googlesource.com/chromium/src/buildtools/': Failed to connect to chromium.googlesource.com port 443: Connection timed out
Traceback (most recent call last):
  File "/work/depot_tools/gclient_scm.py", line 1177, in _Clone
    self._Run(clone_cmd,
  File "/work/depot_tools/gclient_scm.py", line 1518, in _Run
    gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
  File "/work/depot_tools/gclient_utils.py", line 715, in CheckCallAndFilter
    raise subprocess2.CalledProcessError(
subprocess2.CalledProcessError: Command 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src/buildtools /media/xiangang/Repository/webrtc/webrtc-github/src/_gclient_buildtools_luvh_dxs' returned non-zero exit status 128 in /media/xiangang/Repository/webrtc/webrtc-github
[1:29:05] _____ Conflicting directory found in /media/xiangang/Repository/webrtc/webrtc-github/src/buildtools. Moving to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/buildtools5aonwdxq.
----------------------------------------


Warnings:
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/buildtools moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/buildtools5aonwdxq.
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/tools moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/toolsqsruy_96.
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/testing moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/testingzzl4y5lf.
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/base moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/base0c3qxg31.
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/build moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/buildadru8ysv.
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/third_party moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/third_partyrwxgp826.
Conflicting directory /media/xiangang/Repository/webrtc/webrtc-github/src/examples/androidtests/third_party/gradle moved to /media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/examples/androidtests/third_party/gradlexnkdvm5p.
Traceback (most recent call last):
  File "/work/depot_tools/gclient_scm.py", line 647, in update
    self._Clone(revision, url, options)
  File "/work/depot_tools/gclient_scm.py", line 1177, in _Clone
    self._Run(clone_cmd,
  File "/work/depot_tools/gclient_scm.py", line 1518, in _Run
    gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
  File "/work/depot_tools/gclient_utils.py", line 715, in CheckCallAndFilter
    raise subprocess2.CalledProcessError(
subprocess2.CalledProcessError: Command 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src/buildtools /media/xiangang/Repository/webrtc/webrtc-github/src/_gclient_buildtools_luvh_dxs' returned non-zero exit status 128 in /media/xiangang/Repository/webrtc/webrtc-github

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xiangang/.vpython-root/2661ac/lib/python3.8/shutil.py", line 791, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/media/xiangang/Repository/webrtc/webrtc-github/src/buildtools' -> '/media/xiangang/Repository/webrtc/webrtc-github/_bad_scm/src/buildtools5aonwdxq/buildtools'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/depot_tools/metrics.py", line 291, in print_notice_and_exit
    yield
  File "/work/depot_tools/gclient.py", line 3489, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/work/depot_tools/gclient.py", line 3475, in main
    return dispatcher.execute(OptionParser(), argv)
  File "/work/depot_tools/subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "/work/depot_tools/gclient.py", line 3026, in CMDsync
    ret = client.RunOnDeps('update', args)
  File "/work/depot_tools/gclient.py", line 2020, in RunOnDeps
    work_queue.flush(revision_overrides,
  File "/work/depot_tools/gclient_utils.py", line 1013, in flush
    reraise(e[0], e[1], e[2])
  File "/work/depot_tools/gclient_utils.py", line 70, in reraise
    raise value
  File "/work/depot_tools/gclient_utils.py", line 1090, in run
    self.item.run(*self.args, **self.kwargs)
  File "/work/depot_tools/gclient.py", line 1005, in run
    self._got_revision = self._used_scm.RunCommand(command, options, args,
  File "/work/depot_tools/gclient_scm.py", line 128, in RunCommand
    return getattr(self, command)(options, args, file_list)
  File "/work/depot_tools/gclient_scm.py", line 650, in update
    self._DeleteOrMove(options.force)
  File "/work/depot_tools/gclient_scm.py", line 203, in _DeleteOrMove
    shutil.move(self.checkout_path, dest_path)
  File "/home/xiangang/.vpython-root/2661ac/lib/python3.8/shutil.py", line 811, in move
    copy_function(src, real_dst)
  File "/home/xiangang/.vpython-root/2661ac/lib/python3.8/shutil.py", line 435, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/xiangang/.vpython-root/2661ac/lib/python3.8/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/media/xiangang/Repository/webrtc/webrtc-github/src/buildtools'

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github$                                                                                                                                                                                                               

You can see the error:

fatal: unable to access 'https://chromium.googlesource.com/chromium/src/buildtools/': Failed to connect to chromium.googlesource.com port 443: Connection timed out

There are still some tools such as this buildtoosl that need to be downloaded from https://chromium.googlesource.com , because the WebRTC mirror does not contain this tool.
what to do? The simple way is to manually download these tools from other domestic mirrors, but it is very troublesome, because there are still many tools that need to be processed in this way. Look, there are so many, I really want to cry to death.

https://chromium.googlesource.com/chromium/src/base
https://chromium.googlesource.com/chromium/src/build
https://chromium.googlesource.com/chromium/src/buildtools
https://chromium.googlesource.com/external/github.com/gradle/gradle
https://chromium.googlesource.com/chromium/src/ios
https://chromium.googlesource.com/chromium/src/testing
https://chromium.googlesource.com/chromium/src/third_party
https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format
https://chromium.googlesource.com/chromium/llvm-project/libcxx
https://chromium.googlesource.com/chromium/llvm-project/libcxxabi
https://chromium.googlesource.com/external/llvm.org/libunwind
https://chromium.googlesource.com/android_ndk
https://chromium.googlesource.com/android_tools
https://chromium.googlesource.com/external/github.com/google/auto
https://chromium.googlesource.com/catapult
https://chromium.googlesource.com/external/github.com/google/compact_enc_det
https://chromium.googlesource.com/external/colorama
https://chromium.googlesource.com/chromium/tools/depot_tools
https://chromium.googlesource.com/chromium/third_party/errorprone
https://chromium.googlesource.com/chromium/third_party/ffmpeg
https://chromium.googlesource.com/chromium/deps/findbugs
https://chromium.googlesource.com/chromium/src/third_party/freetype2
https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz
https://chromium.googlesource.com/external/github.com/google/gtest-parallel
https://chromium.googlesource.com/external/github.com/google/googletest
https://chromium.googlesource.com/chromium/deps/icu
https://chromium.googlesource.com/external/jsr-305
https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp
https://chromium.googlesource.com/external/junit
https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer
https://chromium.googlesource.com/chromium/deps/libjpeg_turbo
https://chromium.googlesource.com/chromium/deps/libsrtp
https://chromium.googlesource.com/webm/libvpx
https://chromium.googlesource.com/libyuv/libyuv
https://chromium.googlesource.com/linux-syscall-support
https://chromium.googlesource.com/external/mockito/mockito
https://chromium.googlesource.com/chromium/deps/nasm
https://chromium.googlesource.com/external/github.com/cisco/openh264
https://chromium.googlesource.com/external/github.com/kennethreitz/requests
https://chromium.googlesource.com/external/robolectric
https://chromium.googlesource.com/chromium/third_party/ub-uiautomator
https://chromium.googlesource.com/external/github.com/sctplab/usrsctp
https://chromium.googlesource.com/chromium/deps/yasm/binaries
https://chromium.googlesource.com/chromium/deps/yasm/patched-yasm
https://chromium.googlesource.com/chromium/src/tools
https://chromium.googlesource.com/infra/luci/client-py

Head iron, try to continue to execute gclient sync, the result is still the following error:

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ gclient sync
/media/xiangang/Repository/webrtc/webrtc-github/.gclient_entries missing, .gclient file in parent directory /media/xiangang/Repository/webrtc/webrtc-github might not be the file you want to use.
Syncing projects: 100% ( 1/ 1) src
src (ERROR)
----------------------------------------
[0:00:00] Started.
[0:00:00] Finished running: git config remote.origin.url
[0:00:00] Finished running: git rev-list -n 1 HEAD
[0:00:00] Finished running: git rev-parse --abbrev-ref=strict HEAD
----------------------------------------
Error: Command 'git remote update' returned non-zero exit status 1 in /media/xiangang/Repository/webrtc/webrtc-github/src
fatal: unable to access 'https://github.com/ibaoger/webrtc.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.

The most trouble-free, in the end is to use scientific Internet tools. Open the network proxy honestly and execute gclient sync again.
picture.pngAbout an hour later snyc finished!

other ways

Maybe you can consider setting up a foreign cloud server. After a series of source code synchronous compilation, publish the compiled product to Maven. Why not do it? Of course, this method is not without disadvantages, that is, it is expensive and expensive. RMB players can consider this method, just refer to the official tutorial: https://webrtc.github.io/webrtc-org/native-code/android/

Compile WebRTC

If you are using the Ubuntu system, it is generally recommended to execute gclient sync after synchronization: ./build/install-build-deps.sh, which is used to download, install and compile dependencies.
After the preparatory work is done, compiling the source code is very simple. For the compilation process, refer to the documentation on the official website.
picture.png

Generate Ninja project files

WebRTC uses Ninja as the build system by default, and uses GN to generate Ninja project files. We can specify that the Ninja project files are generated in a directory of our choice, such as out/Debug or out/Release.

Use the default value (Debug compilation) to generate the Ninja project file, please execute the following command (the generated project file is located in the src directory of the checkout source code):

gn gen out/Default

Demo:
picture.png
Release compilation, execute the following command to generate the Ninja project file:

gn gen out/Default --args='is_debug=false'

Demo:
picture.png

compile

After generating the Ninja project files through GN, you can use Ninja to compile them.

For the Ninja project file generated in out/Default, execute the following command to compile:

ninja -C out/Default

Demonstration:
picture.pngIt may be that the performance of the computer is good, and the compilation is completed in less than 10 minutes. In the /webrtc/webrtc-github/src/out/Default/obj directory, you can see the compiled static library file: libwebrtc.a.
picture.png

generate aar

Looking at the official tutorial, we found that Google provides a ready-made WebRTC aar package for us to use directly.
picture.png
But if we also want to package it into aar and publish it to maven, will it work? Of course! There is a build_aar.py script in the source code/src/tools_webrtc/android directory for this purpose, isn’t it sweet?
picture.pngBecause it is a python script, it needs a python environment, but often we are prone to stepping on the pit is to use the installed python (included with the system) to execute, and often the execution fails due to version mismatch. In fact, depot_tools uses both python2 and python3.

We open build_aar.py:
picture.pngfound that the first line is #!/usr/bin/env vpython3. You may have a doubt, what is vpython3, and what is the difference with python3? If you read the above-mentioned unfeeling depot_tools principle and implementation blog, you will know that vpython is Google's python virtualization environment, which is mainly used to isolate different versions of python environments, because Google projects use a lot of Python scripts, but some python scripts can only run in a specific version of python, so different versions of python need to be run at the same time. So vpython3 is the virtualization environment of the python3 version provided by Google. It is in the [email protected]_bin directory of depot_tools, as shown in the figure below:
picture.pngTherefore, it is strongly recommended to use the python3 that comes with depot_tools to execute build_aar. py script.

Pay attention to the comments of the script:

The script has to be run from the root src folder.
./tools_webrtc/android/build_aar.py

#!/usr/bin/env vpython3

# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
"""Script to generate libwebrtc.aar for distribution.

The script has to be run from the root src folder.
./tools_webrtc/android/build_aar.py

.aar-file is just a zip-archive containing the files of the library. The file
structure generated by this script looks like this:
 - AndroidManifest.xml
 - classes.jar
 - libs/
   - armeabi-v7a/
     - libjingle_peerconnection_so.so
   - x86/
     - libjingle_peerconnection_so.so
"""

That is to execute in the src directory: ./tools_webrtc/android/build_aar.py, it does not need to be executed by specifying the python3 path

/webrtc/depot_tools/[email protected]_bin/python3/bin/python3 tools_webrtc/android/build_aar.py

We try to execute the command in the src directory: ./tools_webrtc/android/build_aar.py
picture.pngexecution process:

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ ./tools_webrtc/android/build_aar.py
INFO:root:Building: armeabi-v7a
Done. Made 5847 targets from 338 files in 426ms
ninja: Entering directory `/tmp/tmp6ozvfe9z/armeabi-v7a'
[3311/4313] ACTION //sdk/android:base_java__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: obj/sdk/android/base_java.javac.jar obj/sdk/android/base_java.javac.jar.info 
python3 ../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py --depfile=gen/sdk/android/base_java__compile_java.d --generated-dir=gen/sdk/android/base_java/generated_java --jar-path=obj/sdk/android/base_java.javac.jar --java-srcjars=\[\"gen/sdk/android/base_java.generated.srcjar\"\] --target-name //sdk/android:base_java__compile_java --classpath=@FileArg\(gen/sdk/android/base_java.build_config.json:android:sdk_interface_jars\) --header-jar obj/sdk/android/base_java.turbine.jar --classpath=\[\"obj/sdk/android/base_java.turbine.jar\"\] --classpath=@FileArg\(gen/sdk/android/base_java.build_config.json:deps_info:javac_full_interface_classpath\) --chromium-code=1 --warnings-as-errors --jar-info-exclude-globs=\[\"\*/R.class\",\ \"\*/R\\\$\*.class\",\ \"\*/Manifest.class\",\ \"\*/Manifest\\\$\*.class\",\ \"\*/\*GEN_JNI.class\"\] @gen/sdk/android/base_java.sources
注: ../../../media/xiangang/Repository/webrtc/webrtc-github/src/sdk/android/src/java/org/webrtc/RefCountDelegate.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Traceback (most recent call last):
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 823, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in main
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 55, in CallAndWriteDepfileIfStale
    CallAndRecordIfStale(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 154, in CallAndRecordIfStale
    function(*args)
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in <lambda>
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 437, in _OnStaleMd5
    _RunCompiler(changes,
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 570, in _RunCompiler
    build_utils.CheckOutput(cmd,
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/build_utils.py", line 296, in CheckOutput
    raise CalledProcessError(cwd, args, MSG.format(stream_string))
util.build_utils.CalledProcessError: Command failed: ( cd /tmp/tmp6ozvfe9z/armeabi-v7a; ../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -proc:none -d obj/sdk/android/base_java.javac.jar.staging/classes -classpath obj/third_party/android_sdk/android.ijar.jar:obj/sdk/android/base_java.turbine.jar:obj/third_party/androidx/androidx_annotation_annotation_jvm.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib_common.ijar.jar:obj/third_party/android_deps/org_jetbrains_annotations.ijar.jar @obj/sdk/android/base_java.javac.jar.staging/files_list.txt )

Command failed because it wrote to stderr.
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[3315/4313] ACTION //tools/android/errorprone_plugin:errorprone_plugin__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar.info 
python3 ../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py --depfile=gen/tools/android/errorprone_plugin/errorprone_plugin__compile_java.d --generated-dir=gen/tools/android/errorprone_plugin/errorprone_plugin/generated_java --jar-path=obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar --java-srcjars=\[\"gen/tools/android/errorprone_plugin/errorprone_plugin.generated.srcjar\"\] --target-name //tools/android/errorprone_plugin:errorprone_plugin__compile_java --header-jar obj/tools/android/errorprone_plugin/errorprone_plugin.turbine.jar --classpath=\[\"obj/tools/android/errorprone_plugin/errorprone_plugin.turbine.jar\"\] --classpath=@FileArg\(gen/tools/android/errorprone_plugin/errorprone_plugin.build_config.json:deps_info:javac_full_interface_classpath\) --chromium-code=1 --warnings-as-errors @gen/tools/android/errorprone_plugin/errorprone_plugin.sources
注: ../../../media/xiangang/Repository/webrtc/webrtc-github/src/tools/android/errorprone_plugin/src/org/chromium/tools/errorprone/plugin/NoSynchronizedMethodCheck.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Traceback (most recent call last):
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 823, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in main
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 55, in CallAndWriteDepfileIfStale
    CallAndRecordIfStale(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 154, in CallAndRecordIfStale
    function(*args)
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in <lambda>
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 437, in _OnStaleMd5
    _RunCompiler(changes,
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 570, in _RunCompiler
    build_utils.CheckOutput(cmd,
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/build_utils.py", line 296, in CheckOutput
    raise CalledProcessError(cwd, args, MSG.format(stream_string))
util.build_utils.CalledProcessError: Command failed: ( cd /tmp/tmp6ozvfe9z/armeabi-v7a; ../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -proc:none -d obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar.staging/classes -classpath obj/tools/android/errorprone_plugin/errorprone_plugin.turbine.jar:obj/third_party/android_deps/com_google_errorprone_javac.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_core.ijar.jar:obj/third_party/android_deps/org_pcollections_pcollections.ijar.jar:obj/third_party/android_deps/com_google_protobuf_protobuf_java.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_type_annotations.ijar.jar:obj/third_party/android_deps/com_google_auto_auto_common.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_check_api.ijar.jar:obj/third_party/android_deps/org_checkerframework_dataflow_errorprone.ijar.jar:obj/third_party/android_deps/io_github_java_diff_utils_java_diff_utils.ijar.jar:obj/third_party/android_deps/org_eclipse_jgit_org_eclipse_jgit.ijar.jar:obj/third_party/android_deps/com_google_auto_value_auto_value_annotations.ijar.jar:obj/third_party/android_deps/com_github_kevinstern_software_and_algorithms.ijar.jar:obj/third_party/android_deps/com_github_ben_manes_caffeine_caffeine.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_annotation.ijar.jar:obj/third_party/android_deps/com_google_guava_guava.ijar.jar:obj/third_party/android_deps/org_checkerframework_checker_qual.ijar.jar:obj/third_party/android_deps/com_google_j2objc_j2objc_annotations.ijar.jar:obj/third_party/android_deps/com_google_guava_listenablefuture.ijar.jar:obj/third_party/android_deps/com_google_guava_failureaccess.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_annotations.ijar.jar:obj/third_party/android_deps/com_google_code_findbugs_jsr305.ijar.jar:obj/third_party/android_deps/com_google_auto_service_auto_service_annotations.ijar.jar @obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar.staging/files_list.txt )

Command failed because it wrote to stderr.
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[3322/4313] ACTION //modules/audio_device:audio_device_java__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: obj/modules/audio_device/audio_device_java.javac.jar obj/modules/audio_device/audio_device_java.javac.jar.info 
python3 ../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py --depfile=gen/modules/audio_device/audio_device_java__compile_java.d --generated-dir=gen/modules/audio_device/audio_device_java/generated_java --jar-path=obj/modules/audio_device/audio_device_java.javac.jar --java-srcjars=\[\"gen/modules/audio_device/audio_device_java.generated.srcjar\"\] --target-name //modules/audio_device:audio_device_java__compile_java --classpath=@FileArg\(gen/modules/audio_device/audio_device_java.build_config.json:android:sdk_interface_jars\) --header-jar obj/modules/audio_device/audio_device_java.turbine.jar --classpath=\[\"obj/modules/audio_device/audio_device_java.turbine.jar\"\] --classpath=@FileArg\(gen/modules/audio_device/audio_device_java.build_config.json:deps_info:javac_full_interface_classpath\) --chromium-code=1 --warnings-as-errors --jar-info-exclude-globs=\[\"\*/R.class\",\ \"\*/R\\\$\*.class\",\ \"\*/Manifest.class\",\ \"\*/Manifest\\\$\*.class\",\ \"\*/\*GEN_JNI.class\"\] @gen/modules/audio_device/audio_device_java.sources
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Traceback (most recent call last):
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 823, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in main
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 55, in CallAndWriteDepfileIfStale
    CallAndRecordIfStale(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 154, in CallAndRecordIfStale
    function(*args)
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in <lambda>
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 437, in _OnStaleMd5
    _RunCompiler(changes,
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 570, in _RunCompiler
    build_utils.CheckOutput(cmd,
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/build_utils.py", line 296, in CheckOutput
    raise CalledProcessError(cwd, args, MSG.format(stream_string))
util.build_utils.CalledProcessError: Command failed: ( cd /tmp/tmp6ozvfe9z/armeabi-v7a; ../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -proc:none -d obj/modules/audio_device/audio_device_java.javac.jar.staging/classes -classpath obj/third_party/android_sdk/android.ijar.jar:obj/modules/audio_device/audio_device_java.turbine.jar:obj/rtc_base/base_java.turbine.jar:obj/third_party/androidx/androidx_annotation_annotation_jvm.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib_common.ijar.jar:obj/third_party/android_deps/org_jetbrains_annotations.ijar.jar @obj/modules/audio_device/audio_device_java.javac.jar.staging/files_list.txt )

Command failed because it wrote to stderr.
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[3336/4313] ACTION //third_party/android_deps:org_jetbrains_kotlin_kotlin_stdlib_java__dex(//build/toolchain/android:android_clang_arm)
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "./tools_webrtc/android/build_aar.py", line 269, in <module>
    sys.exit(main())
  File "./tools_webrtc/android/build_aar.py", line 263, in main
    BuildAar(args.arch, args.output, args.use_goma, args.use_remoteexec,
  File "./tools_webrtc/android/build_aar.py", line 243, in BuildAar
    Build(build_dir, arch, use_goma, use_remoteexec, extra_gn_args,
  File "./tools_webrtc/android/build_aar.py", line 198, in Build
    _RunNinja(output_directory, ninja_args)
  File "./tools_webrtc/android/build_aar.py", line 129, in _RunNinja
    subprocess.check_call(cmd)
  File "/work/depot_tools/.cipd_bin/.cipd/pkgs/0/Gz9krHL6kKjbvGdxI5atUyCuwSXBMIhmVrK6FblTzSIC/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/media/xiangang/Repository/webrtc/webrtc-github/src/third_party/ninja/ninja', '-C', '/tmp/tmp6ozvfe9z/armeabi-v7a', 'sdk/android:libwebrtc', 'sdk/android:libjingle_peerconnection_so']' returned non-zero exit status 1.
xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ 


The result was wrong. Fortunately, there are tips to tell us the solution: You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).

Ok, then try again: ./tools_webrtc/android/build_aar.py --extra-gn-args "treat_warnings_as_errors=false"
picture.pngThis time it succeeded, the complete execution process is as follows:

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ ./tools_webrtc/android/build_aar.py --extra-gn-args "treat_warnings_as_errors=false"
INFO:root:Building: armeabi-v7a
Done. Made 5847 targets from 338 files in 431ms
ninja: Entering directory `/tmp/tmplq7o6un2/armeabi-v7a'
[3314/4313] ACTION //sdk/android:base_java__compile_java(//build/toolchain/android:android_clang_arm)
注: ../../../media/xiangang/Repository/webrtc/webrtc-github/src/sdk/android/src/java/org/webrtc/RefCountDelegate.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

...省略

The above stderr output was from:
../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED -XDcompilePolicy=simple '-Xplugin:ErrorProne -XepAllErrorsAsWarnings -XepDisableWarningsInGeneratedCode -Xep:InlineMeInliner:OFF -Xep:InvalidParam:OFF -Xep:InvalidLink:OFF -Xep:InvalidInlineTag:OFF -Xep:EmptyBlockTag:OFF -Xep:PublicConstructorForAbstractClass:OFF -Xep:InvalidBlockTag:OFF -Xep:StaticAssignmentInConstructor:OFF -Xep:MutablePublicArray:OFF -Xep:UnescapedEntity:OFF -Xep:NonCanonicalType:OFF -Xep:AlmostJavadoc:OFF -Xep:ReturnValueIgnored:OFF -Xep:InlineMeSuggester:OFF -Xep:DoNotClaimAnnotations:OFF -Xep:JavaUtilDate:OFF -Xep:IdentityHashMapUsage:OFF -Xep:UnnecessaryMethodReference:OFF -Xep:LongFloatConversion:OFF -Xep:CharacterGetNumericValue:OFF -Xep:ErroneousThreadPoolConstructorChecker:OFF -Xep:StaticMockMember:OFF -Xep:MissingSuperCall:OFF -Xep:ToStringReturnsNull:OFF -Xep:MalformedInlineTag:OFF -Xep:DoubleBraceInitialization:OFF -Xep:CatchAndPrintStackTrace:OFF -Xep:SynchronizeOnNonFinalField:OFF -Xep:TypeParameterUnusedInFormals:OFF -Xep:CatchFail:OFF -Xep:JUnitAmbiguousTestClass:OFF -Xep:DefaultCharset:OFF -Xep:UnrecognisedJavadocTag:OFF -Xep:JdkObsolete:OFF -Xep:FunctionalInterfaceClash:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:OperatorPrecedence:OFF -Xep:ThreadJoinLoop:OFF -Xep:StringSplitter:OFF -Xep:ClassNewInstance:OFF -Xep:ClassCanBeStatic:OFF -Xep:FloatCast:OFF -Xep:ThreadLocalUsage:OFF -Xep:Finally:OFF -Xep:FragmentNotInstantiable:OFF -Xep:HidingField:OFF -Xep:IntLongMath:OFF -Xep:BadComparable:OFF -Xep:EqualsHashCode:OFF -Xep:TypeParameterShadowing:OFF -Xep:ImmutableEnumChecker:OFF -Xep:InputStreamSlowMultibyteRead:OFF -Xep:BoxedPrimitiveConstructor:OFF -Xep:OverrideThrowableToString:OFF -Xep:CollectionToArraySafeParameter:OFF -Xep:ObjectToString:OFF -Xep:UnusedMethod:OFF -Xep:UnusedVariable:OFF -Xep:UnsafeReflectiveConstructionCast:OFF -Xep:MixedMutabilityReturnType:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:ExtendingJUnitAssert:OFF -Xep:SystemExitOutsideMain:OFF -Xep:TypeParameterNaming:OFF -Xep:UnusedException:OFF -Xep:UngroupedOverloads:OFF -Xep:FunctionalInterfaceClash:OFF -Xep:InconsistentOverloads:OFF -Xep:SameNameButDifferent:OFF -Xep:UnnecessaryLambda:OFF -Xep:UnnecessaryAnonymousClass:OFF -Xep:LiteProtoToString:OFF -Xep:MissingSummary:OFF -Xep:ReturnFromVoid:OFF -Xep:EmptyCatch:OFF -Xep:BadImport:OFF -Xep:UseCorrectAssertInTests:OFF -Xep:InlineFormatString:OFF -Xep:DefaultPackage:OFF -Xep:RefersToDaggerCodegen:OFF -Xep:RemoveUnusedImports:OFF -Xep:UnnecessaryParentheses:OFF -Xep:UnicodeEscape:OFF -Xep:AlreadyChecked:OFF -Xep:BinderIdentityRestoredDangerously:WARN -Xep:EmptyIf:WARN -Xep:EqualsBrokenForNull:WARN -Xep:InvalidThrows:WARN -Xep:LongLiteralLowerCaseSuffix:WARN -Xep:MultiVariableDeclaration:WARN -Xep:RedundantOverride:WARN -Xep:StaticQualifiedUsingExpression:WARN -Xep:StringEquality:WARN -Xep:TimeUnitMismatch:WARN -Xep:UnnecessaryStaticImport:WARN -Xep:UseBinds:WARN -Xep:WildcardImport:WARN' -XDshould-stop.ifNoError=FLOW -proc:none -processorpath lib.java/tools/android/errorprone_plugin/errorprone_plugin.jar:lib.java/third_party/android_deps/com_google_auto_service_auto_service_annotations.jar:lib.java/third_party/android_deps/com_google_code_findbugs_jsr305.jar:lib.java/third_party/android_deps/com_google_errorprone_error_prone_annotations.jar:lib.java/third_party/android_deps/com_google_guava_failureaccess.jar:lib.java/third_party/android_deps/com_google_guava_listenablefuture.jar:lib.java/third_party/android_deps/com_google_j2objc_j2objc_annotations.jar:lib.java/third_party/android_deps/org_checkerframework_checker_qual.jar:lib.java/third_party/android_deps/com_google_guava_guava.jar:lib.java/third_party/android_deps/com_google_errorprone_error_prone_annotation.jar:lib.java/third_party/android_deps/com_github_ben_manes_caffeine_caffeine.jar:lib.java/third_party/android_deps/com_github_kevinstern_software_and_algorithms.jar:lib.java/third_party/android_deps/com_google_auto_value_auto_value_annotations.jar:lib.java/third_party/android_deps/org_eclipse_jgit_org_eclipse_jgit.jar:lib.java/third_party/android_deps/io_github_java_diff_utils_java_diff_utils.jar:lib.java/third_party/android_deps/org_checkerframework_dataflow_errorprone.jar:lib.java/third_party/android_deps/com_google_errorprone_error_prone_check_api.jar:lib.java/third_party/android_deps/com_google_auto_auto_common.jar:lib.java/third_party/android_deps/com_google_errorprone_error_prone_type_annotations.jar:lib.java/third_party/android_deps/com_google_protobuf_protobuf_java.jar:lib.java/third_party/android_deps/org_pcollections_pcollections.jar:lib.java/third_party/android_deps/com_google_errorprone_error_prone_core.jar:lib.java/third_party/android_deps/com_google_errorprone_javac.jar -Werror -d obj/sdk/android/peerconnection_java__errorprone.errorprone.stamp.staging/classes -classpath obj/third_party/android_sdk/android.ijar.jar:obj/sdk/android/peerconnection_java.turbine.jar:obj/modules/audio_device/audio_device_java.turbine.jar:obj/sdk/android/logging_java.turbine.jar:obj/sdk/android/java_audio_device_module_java.turbine.jar:obj/sdk/android/default_video_codec_factory_java.turbine.jar:obj/sdk/android/swcodecs_java.turbine.jar:obj/sdk/android/libvpx_vp9_java.turbine.jar:obj/sdk/android/libvpx_vp8_java.turbine.jar:obj/sdk/android/dav1d_java.turbine.jar:obj/sdk/android/hwcodecs_java.turbine.jar:obj/sdk/android/video_java.turbine.jar:obj/sdk/android/video_api_java.turbine.jar:obj/sdk/android/builtin_audio_codecs_java.turbine.jar:obj/sdk/android/audio_api_java.turbine.jar:obj/rtc_base/base_java.turbine.jar:obj/sdk/android/base_java.turbine.jar:obj/third_party/androidx/androidx_annotation_annotation_jvm.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib_common.ijar.jar:obj/third_party/android_deps/org_jetbrains_annotations.ijar.jar @obj/sdk/android/peerconnection_java__errorprone.errorprone.stamp.staging/files_list.txt
[4565/4565] SOLINK ./libjingle_peerconnection_so.so
INFO:root:Collecting common files.
INFO:root:Collecting: armeabi-v7a
INFO:root:Collecting: arm64-v8a
INFO:root:Collecting: x86
INFO:root:Collecting: x86_64
INFO:root:List of licenses: webrtc, abseil-cpp, android_deps, android_ndk, android_sdk, androidx, base64, boringssl, crc32c, dav1d, fft, fiat, g711, g722, ijar, jdk, libaom, libc++, libc++abi, libevent, libjpeg_turbo, libsrtp, libunwind, libvpx, libyuv, nasm, ooura, opus, pffft, protobuf, rnnoise, sigslot, spl_sqrt_floor, zlib
INFO:root:Skipping compile time or internal dependency: android_deps
INFO:root:Skipping compile time or internal dependency: androidx
INFO:root:Skipping compile time or internal dependency: jdk
xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ 


The aar file name generated by default is: libwebrtc.aar
picture.pngOpen it and have a look:
picture.pngpicture.png
Compare the aar package provided by Google:
picture.pngthe same, there is no problem. If you want to know more about the usage of parameters of build_aar.py, it is recommended to look at the source code, so I won’t elaborate too much here.
The method of parsing parameters is here:

def _ParseArgs():
  parser = argparse.ArgumentParser(description='libwebrtc.aar generator.')
  parser.add_argument(
      '--build-dir',
      type=os.path.abspath,
      help='Build dir. By default will create and use temporary dir.')
  parser.add_argument('--output',
                      default='libwebrtc.aar',
                      type=os.path.abspath,
                      help='Output file of the script.')
  parser.add_argument('--arch',
                      default=DEFAULT_ARCHS,
                      nargs='*',
                      help='Architectures to build. Defaults to %(default)s.')
  parser.add_argument('--use-goma',
                      action='store_true',
                      default=False,
                      help='Use goma.')
  parser.add_argument('--use-remoteexec',
                      action='store_true',
                      default=False,
                      help='Use RBE.')
  parser.add_argument('--use-unstripped-libs',
                      action='store_true',
                      default=False,
                      help='Use unstripped .so files within libwebrtc.aar')
  parser.add_argument('--verbose',
                      action='store_true',
                      default=False,
                      help='Debug logging.')
  parser.add_argument(
      '--extra-gn-args',
      default=[],
      nargs='*',
      help="""Additional GN arguments to be used during Ninja generation.
              These are passed to gn inside `--args` switch and
              applied after any other arguments and will
              override any values defined by the script.
              Example of building debug aar file:
              build_aar.py --extra-gn-args='is_debug=true'""")
  parser.add_argument(
      '--extra-ninja-switches',
      default=[],
      nargs='*',
      help="""Additional Ninja switches to be used during compilation.
              These are applied after any other Ninja switches.
              Example of enabling verbose Ninja output:
              build_aar.py --extra-ninja-switches='-v'""")
  parser.add_argument(
      '--extra-gn-switches',
      default=[],
      nargs='*',
      help="""Additional GN switches to be used during compilation.
              These are applied after any other GN switches.
              Example of enabling verbose GN output:
              build_aar.py --extra-gn-switches='-v'""")
  return parser.parse_args()

For example, if I want to generate the so of the specified platform, I can execute it like this:

./tools_webrtc/android/build_aar.py --extra-gn-args "treat_warnings_as_errors=false" --arch "armeabi-v7a" "arm64-v8a"

Finally, the generated libwebrtc.aar only contains "armeabi-v7a" and "arm64-v8a" so:
picture.pngthe size of the aar package changes from 41.8M to 17.2M.

Publish aar to GitHubPackages

Why not Sonatype Nexus Repository Manager? Of course, there is no money, and there is still a certain cost to set up an additional cloud server as a Maven warehouse.
Why not publish to the mavenCentral() repository? Of course, it is too much trouble, after all, the aar of WebRTC is only compiled for your own use.
Why not use JitPack? Because JitPack does not support uploading aar directly, you must put a module on Github and let JitPack compile it into aar by itself. Although it is also feasible, it is still a bit troublesome.
After some comparison, I found that GitHubPackages is still pretty good.
Extended reading: Github official documentation GitHubPackages

Publish aarGitHubPackages using the Maven Publish plugin

The use of the Maven Publish plug-in is not introduced much, see the official documentation: https://docs.gradle.org/current/userguide/publishing_maven.html

Open AndroidStudio, create a new WebRTCAndroidMavenPublish project, and then create a maven_publish_libwebrtc module:
image.png
The complete content of the module's build.gradle is as follows:

plugins {
    
    
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'maven-publish'
}

android {
    
    
    namespace 'com.nxg.maven_publish_libwebrtc'
    compileSdk 33

    defaultConfig {
    
    
        minSdk 24
        targetSdk 33

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
    
    
        release {
    
    
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
    
    
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
    
    
        jvmTarget = '1.8'
    }
}

dependencies {
    
    

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

publishing {
    
    

    repositories {
    
    
        maven {
    
    
            name = "GitHubPackages"
            url = "https://maven.pkg.github.com/xiangang/webrtc-android-maven"
            version = '1.0.0'//版本号
            credentials {
    
    
                username = project.findProperty("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR")
                password = project.findProperty("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN")
            }
        }
    }

    publications {
    
    
        androidWebRTC(MavenPublication) {
    
    
            groupId = 'com.github.xiangang'//域名反写
            artifactId = 'libwebrtc'//aar的名称
            artifact "/work/webrtc-checkout/src/libwebrtc.aar"//aar包的目录
        }
    }
}

First reference the maven publish plugin:

plugins {
    
    
    id 'maven-publish'
}

Then you can use this plugin:

publishing {
    
    
    repositories {
    
    
        maven {
    
    
            name = "GitHubPackages"
            url = "https://maven.pkg.github.com/xiangang/webrtc-android-maven"
            version = '1.0.0'//版本号
            credentials {
    
    
                username = project.findProperty("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR")
                password = project.findProperty("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN")
            }
        }
    }

    publications {
    
    
        androidWebRTC(MavenPublication) {
    
    
            groupId = 'com.github.xiangang'//域名反写
            artifactId = 'libwebrtc'//aar的名称
            artifact "/work/webrtc-checkout/src/libwebrtc.aar"//aar包的目录
        }
    }
}

For the use of plug-ins, please refer to the official Github documentation: Use Gradle to publish Java packages . Due to space limitations, I will not be too long-winded.

You need to create your own warehouse, the author here is the warehouse: webrtc-android-maven , generate a dedicated GITHUB_TOKEN for this warehouse, for more information, please see " Using GITHUB_TOKEN for authentication ."

The author's GITHUB_ACTOR and GITHUB_TOKEN are saved in the gradle.properties of the project, and of course they can also be saved in the environment variables of the compilation system.
image.png
The androidWebRTC of publications is named by itself, and you can customize it. Because the aar to be released is ready-made, you need to use artifact to define the path of aar.

When ready, execute the corresponding gradle task to publish.
image.png
Screenshot of the execution process:
image.png
Enter the Github page and you can see the published packages:
image.pngOpen the link:
image.pnguploaded successfully!

Gradle references aar on GitHubPackages

How does gradle reference the aar of GitHubPackage? It's also very simple.
Take the author's article Android audio and video development practice series-04-Android WebRTC push stream to the SRS server to realize the push-pull stream function project as an example, add this maven configuration in the build.gradle of the project root directory as follows:
image.pngimage.png
Note that you must bring credentials, otherwise it cannot be obtained.

allprojects {
    
    
    repositories {
    
    
        jcenter()
        google()
        maven {
    
     url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven {
    
    
            name = "GitHubPackages"
            url = "https://maven.pkg.github.com/xiangang/webrtc-android-maven"
            credentials {
    
    
                username = project.findProperty("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR")
                password = project.findProperty("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN")
            }
        }
        maven {
    
     url 'https://jitpack.io' }
    }
}

Then you might say what if others want to use your aar? Public TOKEN? That's right, you can generate a separate token for referencing aar and make it public. Github does a good job of controlling permissions. Of course, you can upload aar directly, and others can download it locally for use, or upload it to other maven warehouses. The author does not recommend using GitHubPackages, it is too slow.

create your own branch

Generally use the release branch to create your own branch, execute the command to view: git branch -r
image.pngCreate your own branch: git checkout -b xiangang_webrtc origin/main
Execute the synchronization command: gclient sync
image.png

code update

If you need to update the code, you can actually use it just like Git. After updating, use the gcient sync command to synchronize:

git checkout master
git pull origin master
gclient sync
git checkout xiangang_webrtc 
git merge master

Summary of common error reporting solutions

curl: (28) Failed to connect to chrome-infra-packages.appspot.com port 443: Connection timed out

Solution: A stable scientific Internet access tool is needed. The author uses Qv2ray, which is introduced in the previous chapter of downloading and synchronizing WebRTC source code.
image.png

bootstrap_python3: line 32: bootstrap-3.8.0.chromium.8_bin/python3/bin/python3: No such file or directory

Solution: Use scientific online tools.
Why? Let's open bootstrap_python3 and take a look:
image.pnglook at the depot_tools directory, there is indeed no such bootstrap-3.8.0.chromium.8_bin/python3/bin/python3 file. At this point, you may have an idea (it’s the author himself), isn’t it python3 here? I can't just install it directly. Using pyenv also supports multi-version coexistence, and switching at any time, wouldn't it be beautiful. But I'm sorry, if you really do this, you will fall into the pit.

First of all, we have to figure out why there is no bootstrap-3.8.0.chromium.8_bin/python3/bin/python3, is Google forgetting? of course not. Instead, bootstrap-3.8.0.chromium.8_bin is a large file and needs to be downloaded using CIPD tools to connect to https://chrome-infra-packages.appspot.com . depot_tools does not include these large file tools.

CIPD stands for Chrome Infrastructure Package Deployment ( https://chromium.googlesource.com/infra/luci/luci-go/+/main/cipd/README.md) ), which is mainly used to manage binary files used in Google project construction (such as compilers and the like), you can simply think of it as a git system for large files.
All files managed by CIPD can be viewed at ( https://chrome-infra-packages.appspot.com)

Therefore, even if the depot_tools we use is downloaded through domestic mirrors, we still need scientific online tools to further download other large file tools required. Look at these offers on the forum, the same error is reported, the answer is yes, that is, scientific Internet tools are needed.
image.png
image.png

gclient: line 32: exec: python: not found

Solution: Execute export GCLIENT_PY3=1 on the command line. Open gclient, you can see that python is executed.
image.pngBut python is not installed on this machine, and there is no python in the depot_tools directory, only vpython3.
image.pngThat being the case, just use vpython3 directly. According to the code, GCLIENT_PY3==1 uses vpython3.

ERROR at //build/config/sysroot.gni:62:7: Assertion failed.

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ gn gen out/Default
ERROR at //build/config/sysroot.gni:62:7: Assertion failed.
      assert(
      ^-----
Missing sysroot (//build/linux/debian_bullseye_amd64-sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
See //build/config/sysroot.gni:63:11: 
          exec_script("//build/dir_exists.py",
          ^-----------------------------------
This is where it was set.
See //build/config/linux/pkg_config.gni:5:1: whence it was imported.
import("//build/config/sysroot.gni")
^----------------------------------
See //BUILD.gn:24:1: whence it was imported.
import("//build/config/linux/pkg_config.gni")
^-------------------------------------------

Solution: execute build/linux/sysroot_scripts/install-sysroot.py --arch=amd64

ERROR at //build/config/compiler/BUILD.gn:1418:22:

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ gn gen out/Default
ERROR at //build/config/compiler/BUILD.gn:1418:22: Script returned non-zero exit code.
    clang_revision = exec_script("//tools/clang/scripts/update.py",
                     ^----------
Current dir: /media/xiangang/Repository/webrtc/webrtc-github/src/out/Default/
Command: python3 /media/xiangang/Repository/webrtc/webrtc-github/src/tools/clang/scripts/update.py --print-revision --verify-version=16
Returned 1 and printed out:

The expected clang version is llvmorg-16-init-17653-g39da55e8-2 but the actual version is 
Did you run "gclient sync"?

See //build/config/BUILDCONFIG.gn:335:3: which caused the file to be included.
  "//build/config/compiler:cet_shadow_stack",
  ^-----------------------------------------

Solution: Re-execute gclient sync.

FAILED: obj/sdk/android/base_java.javac.jar obj/sdk/android/base_java.javac.jar.info

xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ ./tools_webrtc/android/build_aar.py
INFO:root:Building: armeabi-v7a
Done. Made 5847 targets from 338 files in 426ms
ninja: Entering directory `/tmp/tmp6ozvfe9z/armeabi-v7a'
[3311/4313] ACTION //sdk/android:base_java__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: obj/sdk/android/base_java.javac.jar obj/sdk/android/base_java.javac.jar.info 
python3 ../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py --depfile=gen/sdk/android/base_java__compile_java.d --generated-dir=gen/sdk/android/base_java/generated_java --jar-path=obj/sdk/android/base_java.javac.jar --java-srcjars=\[\"gen/sdk/android/base_java.generated.srcjar\"\] --target-name //sdk/android:base_java__compile_java --classpath=@FileArg\(gen/sdk/android/base_java.build_config.json:android:sdk_interface_jars\) --header-jar obj/sdk/android/base_java.turbine.jar --classpath=\[\"obj/sdk/android/base_java.turbine.jar\"\] --classpath=@FileArg\(gen/sdk/android/base_java.build_config.json:deps_info:javac_full_interface_classpath\) --chromium-code=1 --warnings-as-errors --jar-info-exclude-globs=\[\"\*/R.class\",\ \"\*/R\\\$\*.class\",\ \"\*/Manifest.class\",\ \"\*/Manifest\\\$\*.class\",\ \"\*/\*GEN_JNI.class\"\] @gen/sdk/android/base_java.sources
注: ../../../media/xiangang/Repository/webrtc/webrtc-github/src/sdk/android/src/java/org/webrtc/RefCountDelegate.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Traceback (most recent call last):
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 823, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in main
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 55, in CallAndWriteDepfileIfStale
    CallAndRecordIfStale(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 154, in CallAndRecordIfStale
    function(*args)
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in <lambda>
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 437, in _OnStaleMd5
    _RunCompiler(changes,
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 570, in _RunCompiler
    build_utils.CheckOutput(cmd,
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/build_utils.py", line 296, in CheckOutput
    raise CalledProcessError(cwd, args, MSG.format(stream_string))
util.build_utils.CalledProcessError: Command failed: ( cd /tmp/tmp6ozvfe9z/armeabi-v7a; ../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -proc:none -d obj/sdk/android/base_java.javac.jar.staging/classes -classpath obj/third_party/android_sdk/android.ijar.jar:obj/sdk/android/base_java.turbine.jar:obj/third_party/androidx/androidx_annotation_annotation_jvm.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib_common.ijar.jar:obj/third_party/android_deps/org_jetbrains_annotations.ijar.jar @obj/sdk/android/base_java.javac.jar.staging/files_list.txt )

Command failed because it wrote to stderr.
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[3315/4313] ACTION //tools/android/errorprone_plugin:errorprone_plugin__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar.info 
python3 ../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py --depfile=gen/tools/android/errorprone_plugin/errorprone_plugin__compile_java.d --generated-dir=gen/tools/android/errorprone_plugin/errorprone_plugin/generated_java --jar-path=obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar --java-srcjars=\[\"gen/tools/android/errorprone_plugin/errorprone_plugin.generated.srcjar\"\] --target-name //tools/android/errorprone_plugin:errorprone_plugin__compile_java --header-jar obj/tools/android/errorprone_plugin/errorprone_plugin.turbine.jar --classpath=\[\"obj/tools/android/errorprone_plugin/errorprone_plugin.turbine.jar\"\] --classpath=@FileArg\(gen/tools/android/errorprone_plugin/errorprone_plugin.build_config.json:deps_info:javac_full_interface_classpath\) --chromium-code=1 --warnings-as-errors @gen/tools/android/errorprone_plugin/errorprone_plugin.sources
注: ../../../media/xiangang/Repository/webrtc/webrtc-github/src/tools/android/errorprone_plugin/src/org/chromium/tools/errorprone/plugin/NoSynchronizedMethodCheck.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Traceback (most recent call last):
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 823, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in main
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 55, in CallAndWriteDepfileIfStale
    CallAndRecordIfStale(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 154, in CallAndRecordIfStale
    function(*args)
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in <lambda>
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 437, in _OnStaleMd5
    _RunCompiler(changes,
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 570, in _RunCompiler
    build_utils.CheckOutput(cmd,
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/build_utils.py", line 296, in CheckOutput
    raise CalledProcessError(cwd, args, MSG.format(stream_string))
util.build_utils.CalledProcessError: Command failed: ( cd /tmp/tmp6ozvfe9z/armeabi-v7a; ../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -proc:none -d obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar.staging/classes -classpath obj/tools/android/errorprone_plugin/errorprone_plugin.turbine.jar:obj/third_party/android_deps/com_google_errorprone_javac.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_core.ijar.jar:obj/third_party/android_deps/org_pcollections_pcollections.ijar.jar:obj/third_party/android_deps/com_google_protobuf_protobuf_java.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_type_annotations.ijar.jar:obj/third_party/android_deps/com_google_auto_auto_common.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_check_api.ijar.jar:obj/third_party/android_deps/org_checkerframework_dataflow_errorprone.ijar.jar:obj/third_party/android_deps/io_github_java_diff_utils_java_diff_utils.ijar.jar:obj/third_party/android_deps/org_eclipse_jgit_org_eclipse_jgit.ijar.jar:obj/third_party/android_deps/com_google_auto_value_auto_value_annotations.ijar.jar:obj/third_party/android_deps/com_github_kevinstern_software_and_algorithms.ijar.jar:obj/third_party/android_deps/com_github_ben_manes_caffeine_caffeine.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_annotation.ijar.jar:obj/third_party/android_deps/com_google_guava_guava.ijar.jar:obj/third_party/android_deps/org_checkerframework_checker_qual.ijar.jar:obj/third_party/android_deps/com_google_j2objc_j2objc_annotations.ijar.jar:obj/third_party/android_deps/com_google_guava_listenablefuture.ijar.jar:obj/third_party/android_deps/com_google_guava_failureaccess.ijar.jar:obj/third_party/android_deps/com_google_errorprone_error_prone_annotations.ijar.jar:obj/third_party/android_deps/com_google_code_findbugs_jsr305.ijar.jar:obj/third_party/android_deps/com_google_auto_service_auto_service_annotations.ijar.jar @obj/tools/android/errorprone_plugin/errorprone_plugin.javac.jar.staging/files_list.txt )

Command failed because it wrote to stderr.
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[3322/4313] ACTION //modules/audio_device:audio_device_java__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: obj/modules/audio_device/audio_device_java.javac.jar obj/modules/audio_device/audio_device_java.javac.jar.info 
python3 ../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py --depfile=gen/modules/audio_device/audio_device_java__compile_java.d --generated-dir=gen/modules/audio_device/audio_device_java/generated_java --jar-path=obj/modules/audio_device/audio_device_java.javac.jar --java-srcjars=\[\"gen/modules/audio_device/audio_device_java.generated.srcjar\"\] --target-name //modules/audio_device:audio_device_java__compile_java --classpath=@FileArg\(gen/modules/audio_device/audio_device_java.build_config.json:android:sdk_interface_jars\) --header-jar obj/modules/audio_device/audio_device_java.turbine.jar --classpath=\[\"obj/modules/audio_device/audio_device_java.turbine.jar\"\] --classpath=@FileArg\(gen/modules/audio_device/audio_device_java.build_config.json:deps_info:javac_full_interface_classpath\) --chromium-code=1 --warnings-as-errors --jar-info-exclude-globs=\[\"\*/R.class\",\ \"\*/R\\\$\*.class\",\ \"\*/Manifest.class\",\ \"\*/Manifest\\\$\*.class\",\ \"\*/\*GEN_JNI.class\"\] @gen/modules/audio_device/audio_device_java.sources
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Traceback (most recent call last):
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 823, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in main
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 55, in CallAndWriteDepfileIfStale
    CallAndRecordIfStale(
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/md5_check.py", line 154, in CallAndRecordIfStale
    function(*args)
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 812, in <lambda>
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 437, in _OnStaleMd5
    _RunCompiler(changes,
  File "../../../media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/compile_java.py", line 570, in _RunCompiler
    build_utils.CheckOutput(cmd,
  File "/media/xiangang/Repository/webrtc/webrtc-github/src/build/android/gyp/util/build_utils.py", line 296, in CheckOutput
    raise CalledProcessError(cwd, args, MSG.format(stream_string))
util.build_utils.CalledProcessError: Command failed: ( cd /tmp/tmp6ozvfe9z/armeabi-v7a; ../../../media/xiangang/Repository/webrtc/webrtc-github/src/third_party/jdk/current/bin/javac -g --release 11 -encoding UTF-8 -sourcepath : -Xlint:-dep-ann -proc:none -d obj/modules/audio_device/audio_device_java.javac.jar.staging/classes -classpath obj/third_party/android_sdk/android.ijar.jar:obj/modules/audio_device/audio_device_java.turbine.jar:obj/rtc_base/base_java.turbine.jar:obj/third_party/androidx/androidx_annotation_annotation_jvm.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib.ijar.jar:obj/third_party/android_deps/org_jetbrains_kotlin_kotlin_stdlib_common.ijar.jar:obj/third_party/android_deps/org_jetbrains_annotations.ijar.jar @obj/modules/audio_device/audio_device_java.javac.jar.staging/files_list.txt )

Command failed because it wrote to stderr.
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[3336/4313] ACTION //third_party/android_deps:org_jetbrains_kotlin_kotlin_stdlib_java__dex(//build/toolchain/android:android_clang_arm)
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "./tools_webrtc/android/build_aar.py", line 269, in <module>
    sys.exit(main())
  File "./tools_webrtc/android/build_aar.py", line 263, in main
    BuildAar(args.arch, args.output, args.use_goma, args.use_remoteexec,
  File "./tools_webrtc/android/build_aar.py", line 243, in BuildAar
    Build(build_dir, arch, use_goma, use_remoteexec, extra_gn_args,
  File "./tools_webrtc/android/build_aar.py", line 198, in Build
    _RunNinja(output_directory, ninja_args)
  File "./tools_webrtc/android/build_aar.py", line 129, in _RunNinja
    subprocess.check_call(cmd)
  File "/work/depot_tools/.cipd_bin/.cipd/pkgs/0/Gz9krHL6kKjbvGdxI5atUyCuwSXBMIhmVrK6FblTzSIC/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/media/xiangang/Repository/webrtc/webrtc-github/src/third_party/ninja/ninja', '-C', '/tmp/tmp6ozvfe9z/armeabi-v7a', 'sdk/android:libwebrtc', 'sdk/android:libjingle_peerconnection_so']' returned non-zero exit status 1.
xiangang@xiangang-ubuntu:/media/xiangang/Repository/webrtc/webrtc-github/src$ 


Solution: Change ./tools_webrtc/android/build_aar.py to ./tools_webrtc/android/build_aar.py --extra-gn-args "treat_warnings_as_errors=false".

summary

If you plan to download and compile the WebRTC source code from the official website, you will encounter many difficulties if you cannot directly connect to the external network. Although there are WebRTC mirrors at present, some tools such as vpython still have to be downloaded from foreign servers, and buildtools such as chromium are not in the WebRTC warehouse, so if you don’t have scientific Internet tools, don’t torture yourself, it’s really a pit Very troublesome.

Fortunately, if you read this article and you plan to compile the WebRTC source code, many common pitfalls can be skipped, helping you save a lot of time.

operate no scientific internet tools There are scientific online tools
Download depot_tools Difficulty level: ★★☆☆☆ Difficulty: ★☆☆☆☆
Download WebRTC source code Difficulty: ★★★★☆ Difficulty: ★☆☆☆☆
Domestic mirror Google Warehouse Github mirror
Recommended index: ☆☆☆☆☆ Recommended index: ★★★★★ Recommended Index: ★☆☆☆☆

In short, the easiest and most recommended is to enable the network proxy, follow the official documentation, download the source code from the Google warehouse, and start your compilation process. I wish you all the best! For more questions, please leave a message to communicate.

Written at the end, first of all, thank you very much for your patience in reading the entire article. It is not easy to insist on writing original and practical articles. If this article happens to be helpful to you, you are welcome to like and comment on the article. Your encouragement is the author's insistence Unrelenting drive. If there are any mistakes in the article, please correct me, thank you again.

References

Google official WebRTFC: https://webrtc.googlesource.com/src
WebRTC mirror source provided by Agora WebRTC team: https://webrtc.org.cn/mirror
Github WebRTC mirror: https://github.com/ibaoger /webrtc.git's
article to get WebRTC |Android client compilation

Guess you like

Origin blog.csdn.net/xiangang12202/article/details/128962094