折腾了好几天,终于把webrtc android编译成功了,不禁感慨:webrtc android编译实在太难了,但是编译成功之后,感觉实在又太简单了,简单是因为webrtc所有编译工作已经全部都写在了脚本里了,你甚至不不需要去管什么JDK,Android sdk,ndk环境配置等等,因为所有这一切只需要执行一个脚步命令,统统搞定,简直就是良心之作啊 ,哈哈。 但是如果你完全按照官方文档来,还是会碰到各种奇葩问题,有些问题甚至连万能的google也找不到答案,为什么会出现这种状况呢?那是因为很多基础的软件安装,代理等等并没有提到,人家可能认为这本来是很简单的事情,根本没必要教你,但是如果你的系统缺少了一两个软件或者配置,后面会引出一连串问题,这就是难点所在。下面简单介绍下webrtc android编译步骤:
一 环境
先说一下我编译的环境:mac os +虚拟机VirtuaBox+ubuntu 14.04 LTS android的编译必须要在linux下,新装的ubuntu系统默认是不能全屏显示的,需要安装vbox增强工具VBoxGuestAdditions,这个工具还可以实现mac与ubuntu的文件共享,具体可以参考:http://www.2cto.com/os/201308/233609.html
二 基础软件安装
1 源更新,在ubuntu终端中执行:apt-get update,确保这一步都成功了再往下走
2 安装基础软件, 执行:sudo apt-get install git apache2 curl libcurl3 libcurl3-dev php5-curl
三 下载webrtc android 源码
1 设置代理,这一步不做过多介绍,需要注意的是需要在终端设置代理,这一步也是比较坑的一步,大家可以搜一下怎么设置
2 下载 depot_tools:git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git 注意:这一步是在当前user目录下执行的
3 配置depot_tools环境变量:export PATH=`pwd`/depot_tools:"$PATH", 配置成功可以执行gclient命令,看看是否成功
4 下载源码:先创建一个目录比如webrtc,用于存放源码:mkdir webrtc 切换到webrtc目录下:cd webrtc 现在当前目录到了webrtc下,然后执行:
fetch --nohooks webrtc_android
gclient sync
下载是一个漫长的时间,中间可能会因为网络问题中断,中断后继续执行这个进行下载,下载过程中可能提示什么更新google play什么的鬼玩意,执行更新即可,我下载过程 中还提示了什么代理boto异常,最后折腾了好久才解决
四 编译源码
注意:先要安装jdk8的版本
1 安装编译需要的软件及配置 :src/build/install-build-deps-android.sh
2 进入到src目录下 执行:. build/android/envsetup.sh 这一步是配置环境变量(注意前面那个 .)
3 开始编译,编译没什么好说的,完全按照webrtc官网来(如果出现失败的情况,可能代码没有同步完全,还得继续执行gclient sync)
https://www.linuxidc.com/Linux/2014-10/108084.htm还要参考这个网址的过程
gn gen out/Debug --args='target_os="android" target_cpu="arm"'
ninja -C out/Debug
在编译的时候,如果出现ninja: error: '../../third_party/android_tools/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/10.2.0/play-services-base-10.2.0.aar', needed by 'obj/third_party/android_tools/google_play_services_base_java__unpack_aar.inputdeps.stamp', missing and no known rule to make it
还需要重新执行
$ cd third_party/android_tools
$ git log -n 1
commit b77dc4487150b1194894c2173609d91ba2ecbbf7
You could also run 'git status' to see if the directory is in the correct state. If there is a lot of weird stuff going on there, you could clean that whole directory, and in third_party/android_tools then run:
$ git clean -xfd
If the commit in that repository is wrong you could try running these commands:
$ gclient sync
$ build/install-build-deps-android.sh
$ gclient runhooks
最后再下载gooleplay软件的时候,选择y。
This is the first time I try to compile chromium . I followed official guideline and check it out successfully yesterday. But I ran into an error when I tried to build chromium for android :
ninja -C out/Default chrome_public_apk
ninja: Entering directory `out/Default'
ninja: error: '../../third_party/android_tools/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/10.2.0/play-services-base-10.2.0.aar', needed by 'obj/third_party/android_tools/google_play_services_base_java__unpack_aar.inputdeps.stamp', missing and no known rule to make it
Should I build sth. else first ?
Regards !
Xiaoming Ding
Tommy Nyquist |
17/9/11 |
其他收件人: zhao...@gmail.com
将帖子翻译为中文
Could there be that something has happened to the third_party/android_tools part of your checkout?
According to the DEPS file, that directory should be at the commit aadb2fed04af8606545b0afe4e3060bc1a15fad7.
If you do:
$ cd third_party/android_tools
$ git log -n 1
commit b77dc4487150b1194894c2173609d91ba2ecbbf7
You could also run 'git status' to see if the directory is in the correct state. If there is a lot of weird stuff going on there, you could clean that whole directory, and in third_party/android_tools then run:
$ git clean -xfd
If the commit in that repository is wrong you could try running these commands:
$ gclient sync
$ build/install-build-deps-android.sh
$ gclient runhooks
耐心等待编译完成,只要前几部没什么问题,这一步还是很顺利的,成功后可以在out/Debug 下找到编译好的apk demo文件及so,jar包等等
总结:编译成功后,你会发现原来如此简单,但又不简单,其中下载源码这一步最难,其中原因相信你懂的