一、前言
Android development is only supported on Linux.
—https://webrtc.org/native-code/android/#
二、资源清单
1.Linux虚拟机
1G内存足够、100G硬盘空间、Nat模式网络连接
2.翻墙工具
网上一堆
3.教程
https://blog.csdn.net/ericbar/article/details/83114015(基本教程)
https://webrtc.org/native-code/android/#(官方教程-看一下就行)
三、环境配置(已有虚拟机环境可跳过)
1.虚拟机代理配置
export HTTP_PROXY="http://<主机vmnet1地址>:<代理软件port>"
export HTTPS_PROXY="http://<主机vmnet1地址>:<代理软件port>"
- 1
- 2
备注:<主机vmnet1地址>:主机用于和虚拟机通信的虚拟网卡,一般和虚拟机不在同一网段
<代理软件port>:一般代理软件默认为1080
例:
export HTTP_PROXY="http://192.168.235.1:1080"(虚拟机ip:192.168.7.235)
export HTTPS_PROXY="http://192.168.235.1:1080"
- 1
- 2
四、下载代码
1.下载depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- 1
2.下载源码
mkdir webrtc
cd webrtc
fetch --nohooks webrtc_android
gclient sync(上一步中断或者完成后,运行这个)
- 1
- 2
- 3
- 4
3.安装Android依赖
./src/build/install-build-deps.sh
./src/build/install-build-deps-android.sh
- 1
- 2
4.加载环境变量
source build/android/envsetup.sh
- 1
5.切换分支
cd src
git branch -r(查看一下远程分支,选择58分支)
git checout -b webrtc-58 remotes/branch-heads/
gclient sync
- 1
- 2
- 3
- 4
6.生成ninja
gn gen out/Debug --args='target_os="android" target_cpu="arm"'
- 1
7.编译
ninja -C out/Debug AppRTCMobile
- 1
五、问题汇总
1.buid_with_chromium undefine
原因:分支代码未完全同步
解决:58分支下执行 gclient sync
2.libtinfo.so.5 no such file
原因:未建立libncurses5的软连接
解决:ln -s <libncurses5.so.5’s path> /lib/libtinfo.so.5
3.libtinfo.so.5: wrong ELF class: ELFCLASS32
原因:编译器想要64位的libncurses5.so.5,你却给了32位的
解决:
1.sudo apt-get install libncurses5:amd64
2.sudo rm /lib/libtinfo.so.5
3.ln -s <libncurses5.so.5's path that contain x86_64> /lib/libtinfo.so.5
- 1
- 2
- 3