webrtc android版本的编译及release版本的获取

本文主要介绍如何在ubuntu16.0.4平台下编译android版本的webrtc。对于刚开始使用webrtc的人来说,本篇博客可能对你有所帮助!对于健忘的我来说,也算是一种学习笔记,当有需要的时候,回头过来翻看一下也是极好的。好了,进入正题:

注意:编译前请确认你已经翻墙了。

  1. 下载google提供的一系列工具,即工具包(必须)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  1. 配置PATH环境变量,使用google的工具可以直接使用
export PATH=$PATH:/path/to/depot_tools

这个命令仅对当前终端有效果,如果想要全局生效,那可以把该语句写入到.bashrc中,再执行source ~/.bashrc使之生效。

  1. 获取webrtc源码
fetch --nohooks webrtc_android
  1. 同步代码(更新代码)
gclient sync

过程中可能会出现一些告警信息:“To use a proxy in this situation, please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var.”,此时需要配置.boto文件,网上有相关的解决方案,我就不做搬运工了。
最后会有一个lience的确认,输入Y即可。

  1. 如果需要下载webrtc的release版本,参考官网

5.1 查看可用的release版本:git branch -r
5.2 获取指定版本的webrtc源码:git checkout -b my_branch refs/remotes/branch-heads/43。注意:不同源码与depot_tools工具包的版本有一些对应关系,所以如果在更新过程中出现错误,最好先把depot_tools更新到与webrtc源码发布临近的时候版本。
5.3 具体如何获取release-branch,看这里
5.3.1:

#以下的官网的原话,英文不好,就不做翻译了
#Make sure you are in 'src'.
#This part should only need to be done once, but it won't hurt to repeat it. The first
#time checking out branches and tags might take a while because it fetches an extra
#1/2 GB or so of branch commits.
 
gclient sync --with_branch_heads --with_tags

5.3.2

#You may have to explicitly 'git fetch origin' to pull branch-heads/
git fetch

5.3.3

# Checkout the branch 'src' tree.
git checkout -b branch_$BRANCH branch-heads/$BRANCH

5.3.4

# Checkout all the submodules at their branch DEPS revisions.
#该步骤会同步代码,需要一点时间,等到完成后即可以,其它的编译步骤与官网所给出的步骤一致。
gclient sync --with_branch_heads --with_tags

5.3.5

gclient sync
#此时可能会报错,如下:
#src/third_party at a3a6c8af12026c268349ddecd0dc5643a6ea6cae
#You have unstaged changes.
#Please commit, stash, or reset.
#说第三方库有改动,但git diff及git status并没有发现哪里有改动啊?怎么办?最笨的办法就是#备份一下third_pardy然后删除它,重新执行gclient sync,如果大家有更好的处理办法,一起分#享出来。
  1. 利用gn进行编译

6.1 gn的详细使用
gn gen out/armeabi-v7a --args=‘target_os=“android” target_cpu=“arm” is_debug=false use_rtti=true’

6.2:ninja -C out/armeabi-v7a

6.3:
打包aar命令:tools_webrtc/android/build_aar.py

猜你喜欢

转载自blog.csdn.net/TopsLuo/article/details/86543900