Android
- Getting the Code
- Compiling
- Using the Bundled Android SDK/NDK
- Running the AppRTCMobile App
- Running WebRTC Native Tests on an Android Device
- Running WebRTC Instrumentation Tests on an Android Device
Getting the Code
Android development is only supported on Linux.
-
Install prerequisite software
-
Create a working directory, enter it, and run:
fetch --nohooks webrtc_android gclient sync
This will fetch a regular WebRTC checkout with the Android-specific parts added. Notice that the Android specific parts like the Android SDK and NDK are quite large (~8 GB), so the total checkout size will be about 16 GB. The same checkout can be used for both Linux and Android development since you can generate your Ninja project files in different directories for each build config.
See Development for instructions on how to update the code, building etc.
Compiling
-
Generate projects using GN.
Make sure your current working directory is src/ of your workspace. Then run:
gn gen out/Debug --args='target_os="android" target_cpu="arm"'
You can specify a directory of your own choice instead of
out/Debug
, to enable managing multiple configurations in parallel.- To build for ARM64: use
target_cpu="arm64"
- To build for 32-bit x86: use
target_cpu="x86"
- To build for 64-bit x64: use
target_cpu="x64"
- To build for ARM64: use
-
Compile using:
ninja -C out/Debug
Using the Bundled Android SDK/NDK
In order to use the Android SDK and NDK that is bundled in
third_party/android_tools
, run this to get it included in your PATH
(from
src/
):
. build/android/envsetup.sh
Then you’ll have adb
and all the other Android tools in your PATH
.
Running the AppRTCMobile App
AppRTCMobile is an Android application using WebRTC Native APIs via JNI (JNI wrapper is documented here).
For instructions on how to build and run, see webrtc/examples/androidapp/README.
Running WebRTC Native Tests on an Android Device
To build APKs with the WebRTC native tests, follow these instructions.
-
Ensure you have an Android device set in Developer mode connected via USB.
-
Compile as described in the section above.
-
To see which tests are available: look in
out/Debug/bin
. -
Run a test on your device:
out/Debug/bin/run_modules_unittests
-
If you want to limit to a subset of tests, use the
--gtest_filter flag
, e.g.out/Debug/bin/run_modules_unittests \ --gtest_filter=RtpRtcpAPITest.SSRC:RtpRtcpRtcpTest.*
-
NOTICE: The first time you run a test, you must accept a dialog on the device!
If want to run Release builds instead; pass is_debug=false
to GN (and
preferably generate the projects files into a directory like out/Release
).
Then use the scripts generated in out/Release/bin
instead.
Running WebRTC Instrumentation Tests on an Android Device
The instrumentation tests (like AppRTCMobileTest and libjingle_peerconnection_android_unittest) gets scripts generated in the same location as the native tests described in the previous section.