-
Notifications
You must be signed in to change notification settings - Fork 209
Developing Android apps
This page shows how to get started developing Android apps using OpenWebRTC and Android Studio. The process differs slightly depending on what application you are creating, but there are basically 2 different kind of apps:
- Native - Low-level apps that use the OpenWebRTC API.
- Hybrid - Apps that use a combination of Java code and HTML/JavaScript running in web views.
Before you can add OpenWebRTC to your Android Studio project, you need to build it.
Once OpenWebRTC has been built, you will find openwebrtc.jar
and openwebrtc_bridge.jar
inside cerbero/dist/android_armv7/lib/jni
. openwebrtc.jar
contains the base OpenWebRTC library, this is all you need if you want to create a native application. openwebrtc_bridge.jar
contains the OpenWebRTC javascript bridge, which will enable you to use the WebRTC API inside Android WebViews. If you are developing a hybrid app, you will need both openwebrtc.jar
and openwebrtc_bridge.jar
.
Copy or symlink the required .jar files to your app/libs/
folder inside your Android Studio project. Then add compile files('libs/<name>')
for each .jar to you dependencies block inside app/build.gradle
, e.g.
dependencies {
compile files('libs/openwebrtc.jar')
}
If you have another dependency in your project that includes libs with a different abi than OpenWebRTC is built for (armeabi), the OpenWebRTC libs might not get copied properly when your app is installed on a device. This can be solved by adding the following to the config inside the android block in app/build.gradle
:
ndk {
abiFilter "armeabi-v7a"
}
e.g.
defaultConfig {
applicationId "com.example.owr"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk {
abiFilter "armeabi"
}
}
#Step 3. Getting started with development
Before you can use OpenWebRTC in your app, it needs to be initialized. If you are creating a native application, this is done with Owr.init()
, while a hybrid application is initialized with OwrBridge.start()
.
- Minimal native example showing a self-view
- Minimal hybrid example showing a self-view
- Native example that connects to demo.openwebrtc.io
Once OpenWebRTC has been built for Android, the documentation can be found in cerbero/dist/android_armv7/share/javadoc/openwebrtc