10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WebRTC Android向けネイティブビルド手順

Last updated at Posted at 2016-03-01

自分の環境でうまくいっただけのメモ書き
説明等は全て省いてコマンドのみ列挙

#想定環境
OS : Ubuntu 14.04
ビルドターゲット : Androidのみ

#ビルド手順

#rootで作業
$ sudo su
#必要なものインストール
$ apt-get update
$ apt-get upgrade
$ apt-get install -y libnss3-dev libasound2-dev libpulse-dev libjpeg62-dev libxv-dev libgtk2.0-dev libexpat1-dev lib32z1 zlib1g lib32stdc++6 lib32z1-dev $ ant git subversion openjdk-7-jdk g++
#パス通す
$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
#作業用ディレクトリ作る
$ mkdir webrtc  
$ cd webrtc

#下記ビルド用コマンド群  
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git  
$ export PATH=`pwd`/depot_tools:"$PATH"  
$ export GYP_DEFINES="OS=android"  
$ fetch webrtc_android  
$ gclient sync  
$ ./src/build/install-build-deps.sh  
$ export WEBRTC_RELEASE=true  
$ export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_java=1 enable_android_opensl=0 $GYP_DEFINES"  
#↓これ変わりました。追記参照
$ gclient runhooks  

#ビルドコマンド  
$ ninja -C out/Release AppRTCDemo

out/Release/AppRTCDemo/libs/armeabi-v7a/libjingle_peerconnection_so.so
out/Release/gen/libjingle_peerconnection_java/libjingle_peerconnection_java.jar
とか使う

最初の一回目を想定しているのでfetchやapt-getとかも入ってますがこれは一回だけでいいです。
次回からはgclient syncコマンドで続きから始めてくれます

##2016/11/08 追記

いつからか把握してできてないですがGYPがdeprecatedになりました。
その影響でgclient runhooksはやらず、GNコマンドになります
https://webrtc.org/native-code/android/

OS : Ubuntu 14.04 or 16.04

#これ使わない×
$ gclient runhooks 

#これ使う○
$ gn gen out/Default --args='target_os="android" target_cpu="arm"'

その際自分の環境では下記エラーが出たので、解決法を記載

Current dir: /path/src/out/Default/
Command: python -- /path/android/webrtc/src/build/android/gyp/aar.py --input-file ../../third_party/android_tools/sdk/extras/google/m2repository/com/google/android/gms/play-services-basement/9.8.0/play-services-basement-9.8.0.aar --list
Returned 1.
stderr:

Traceback (most recent call last):
  File "/path/android/webrtc/src/build/android/gyp/aar.py", line 109, in <module>
    sys.exit(main())
  File "/path/android/webrtc/src/build/android/gyp/aar.py", line 80, in main
    with zipfile.ZipFile(aar_file) as z:
  File "/usr/lib/python2.7/zipfile.py", line 756, in __init__
    self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: '../../third_party/android_tools/sdk/extras/google/m2repository/com/google/android/gms/play-services-basement/9.8.0/play-services-basement-9.8.0.aar'

See //third_party/android_tools/BUILD.gn:150:1: whence it was called.
android_aar_prebuilt("google_play_services_basement_java") {
^-----------------------------------------------------------
See //webrtc/system_wrappers/BUILD.gn:158:7: which caused the file to be included.
      "//third_party/android_tools:cpu_features",
      ^-----------------------------------------
Build AppRTCMobile in Release (arch: x86_64)
Running ninja
ninja: Entering directory `out/Default'
ninja: error: loading 'build.ninja': No such file or directory

GooglePlayServiceがインストールできてないので下記でインストールする
/path/src/third_party/android_tools/sdk/tools/android sdk
下の方のExtrasにある「Google Repository」をインストール
参考:http://dev.classmethod.jp/smartphone/android/android-studio-support-repository/

以上

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?