Thursday, May 7, 2015

Building WebRTC libraries for Android

   After banging my head almost 2 weeks trying to build WebRTC libraries on Windows and MAC machine, as of today I have successfully compiled WebRTC binaries for Android using this awesome tutorial from here http://www.khirman.com/building-webrtc-libraries-android/

   Anyone reading this post, I would like to suggest don't waste time trying to build on Windows or MAC, it doesn't help, only surges your frustration.

   Linux is the only way out to compile WebRTC, I used Ubuntu 14.04.2 LTS setup in VirtualBox on a MAC.
  
   The following is the list of commands (taken from above site) that I used to compile the libraries.


# assuming we are starting from "virgin" Ubuntu installation
sudo apt-get install git
sudo apt-get install g++
sudo apt-get install subversion
sudo apt-get install git-svn
sudo apt-get install openjdk-7-jdk
sudo apt-get install ant
sudo apt-get install lib32stdc++6 lib32z1
#
# get google build tools
#
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
#
# we'll need Java
#
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
#
# now we are setting our target for compilation
#
export GYP_DEFINES="OS=android"
#
# New home for WebCRT
#
mkdir WebCRT
cd WebCRT
#
# Time to pull sources ( including all dependencies derived from chromium project)
# will take quite a time
#
fetch webrtc_android
#
# Now time to build
#
cd src
#
# setup Android cross compiler build environment
#
. build/android/envsetup.sh
export GYP_DEFINES="build_with_chromium=0  $GYP_DEFINES"
export GYP_DEFINES="build_with_libjingle=1 $GYP_DEFINES"
export GYP_DEFINES="libjingle_java=1 $GYP_DEFINES"
# send WEBRTC_LOGGING to Android's logcat
export GYP_DEFINES="enable_tracing=1 $GYP_DEFINES"
#
# Generate .ninja files
#
gclient runhooks
#
# and now is an actual build....
#

#
# Build AppRTCDemo application – demonstrates interoperability of native Android
# client and Chrome JavaScript client.
# source code / project root : src/talk/examples/android/
# resulting APK : src/out/Debug/AppRTCDemo-debug.apk
#
ninja -C out/Debug AppRTCDemo
#
# Build WebRTCDemo application – exchange video+audio between two
# android clients.
# source code / project root : src/webrtc/examples/android/media_demo/
# resulting APK : src/out/Debug/WebRTCDemo-debug.apk
#
ninja -C out/Debug WebRTCDemo

One small addition, post the gclient  runhooks command in list above use this command to generate all the libraries and apks

ninja -C out/Debug

I am re-posting all the commands here just for my future reference, but might help someone else trying to build the libs.

No comments:

Post a Comment