Edit on GitHub
Platform: iOS Android WPF

Using Gradle

Expand the app folder and open the build.gradle file.

Add the following to the android section of the application's build.gradle (the one in the app folder).

// workaround for "duplicate files during packaging of APK" issue
// see
packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'

Next, add the following to the dependencies section.

compile 'com.couchbase.lite:couchbase-lite-android:1.3.1'

The dependencies section should look similar to this.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''
    compile 'com.couchbase.lite:couchbase-lite-android:1.3.1'

In the Android Studio tool bar, click Sync Project with Gradle Files.

Supported architectures

The list of supported Android architectures depends on the storage type (i.e. SQLite or ForestDB). For SQLite databases, all architectures are supported:

armeabi-v7a x86 arm64-v8a x86_64 mips64 armeabi mips
Yes Yes Yes Yes Yes Yes Yes

For ForestDB databases, the supported architectures are:

armeabi-v7a x86 arm64-v8a x86_64 mips64 armeabi mips
Yes Yes Yes Yes Yes No No

Optional packages

The SDK contains other dependencies that are optional. Here's what each one does:

  • couchbase-lite-java-listener: To access the database through HTTP (often used for hybrid development and peer-to-peer sync). Add it to your Android Studio project using Gradle.

    compile 'com.couchbase.lite:couchbase-lite-java-listener:1.3.1'

    Note: Android emulators run as separate VMs with a different network interface. You can use the adb forward tcp:5984 tcp:5984 command to access the Listener running on the Android emulator from the host machine.

  • couchbase-lite-android-forestdb: To use the ForestDB storage type.

    compile 'com.couchbase.lite:couchbase-lite-android-forestdb:1.3.1'
  • couchbase-lite-android-sqlcipher: To enable encryption on SQLite databases.

    compile 'com.couchbase.lite:couchbase-lite-android-sqlcipher:1.3.1'

Getting Started

Create a new project in Android Studio.

Add Couchbase Lite Android as a dependency using the instructions above.

Open com.couchbase.UntitledApp/ in Android Studio.

Add the following in the onCreate method.

// Create a manager
Manager manager = null;
try {
    manager = new Manager(new AndroidContext(getApplicationContext()), Manager.DEFAULT_OPTIONS);
} catch (IOException e) {
// Create or open the database named app
Database database = null;
try {
    database = manager.getDatabase("app");
} catch (CouchbaseLiteException e) {
// The properties that will be saved on the document
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("title", "Couchbase Mobile");
properties.put("sdk", "Java");
// Create a new document
Document document = database.createDocument();
// Save the document to the database
try {
} catch (CouchbaseLiteException e) {
// Log the document ID (generated by the database)
// and properties
Log.d("app", String.format("Document ID :: %s", document.getId()));
Log.d("app", String.format("Learning %s with %s", (String) document.getProperty("title"), (String) document.getProperty("sdk")));

Click the Debug button. The document ID and properties are logged in LogCat.