1. 程式人生 > >webrtc android 編譯

webrtc android 編譯

折騰了好幾天,終於把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)

  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

其他收件人: [email protected]

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包等等

總結:編譯成功後,你會發現原來如此簡單,但又不簡單,其中下載原始碼這一步最難,其中原因相信你懂的