Tutorial: Quickstart

Android Quickstart

Configure your Android project

Using Webcom repositories...

  1. No special configuration is required in the build.gradle, as the android library is available on the Maven Central repository. However, if you need to test snapshot versions, you have to add our snapshot repository:
allprojects {
    repositories {
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
  1. Declare the android library as a project dependency. The library's resources and permissions will be merged automatically with yours.
    In the build.gradle file of your modules (don't forget to replace <target-version> with the desired version):
dependencies {
    compile 'com.orange.webcom:sdk-android:<target-version>'

...Or using library file

  1. Download the SDK library at:

  2. Save it in the aars/ folder of your modules.

  3. Declare dependencies in the build.gralde file of your modules:

repositories {
    flatDir {
        dirs 'aars'
dependencies {
    compile 'com.orange.webcom:sdk-android:+@aar'
    // SDK dependencies
    compile 'org.mozilla:rhino:'
    compile 'com.orhanobut:logger:1.15'
    compile 'com.koushikdutta.async:androidasync:2.2.1'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.9.3'
    compile 'com.android.support:customtabs:27.1.0'

Manage the conflicting files merged from dependent libraries

The Android SDK for Webcom uses itself 3rd-party open source libraries. Their license files may conflict when Android Studio builds your project, as they are usually named the same way. To avoid this, you can include in the build.gradle file of your modules:

android {
    packagingOptions {
        pickFirst 'LICENSE.txt'
        pickFirst 'META-INF/LICENSE'
        pickFirst 'META-INF/NOTICE'

Note: As most of open source licenses require to be included in your software, don't forget to include them by other means before distributing it.

Start coding

API is similar to the web SDK (replace “<your-app>” with your actual application identifier):

Webcom myRef = new Webcom("<your-app>");

// Read data
myRef.on(Query.Event.CHILD_ADDED, new OnQuery() {
  public void onComplete(DataSnapshot snapData, @Nullable String prevName) {
    // code to handle current data
    Map<String, Object> data = (Map) snapData.value();
  public void onCancel(WebcomError error) {
    // event subscription was canceled because of permission reason
  public void onError(WebcomError error) {
    // an error occured

// Write data
myRef.set(new HashMap() {
  { put("foo", new HashMap() {
    { put("bar", "baz"); }
  }); }

See the API reference for more details.