Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.kiwiwearables:couchbase-lite-android:1.3.1'
}
dependencies {
implementation("com.github.kiwiwearables:couchbase-lite-android:1.3.1")
}
<dependency>
<groupId>com.github.kiwiwearables</groupId>
<artifactId>couchbase-lite-android</artifactId>
<version>1.3.1</version>
</dependency>
libraryDependencies += "com.github.kiwiwearables" % "couchbase-lite-android" % "1.3.1"
:dependencies [[com.github.kiwiwearables/couchbase-lite-android "1.3.1"]]
Couchbase-Lite-Android is a lightweight embedded NoSQL database engine for Android with the built-in ability to sync to Couchbase Server on the backend.
It is the Android port of Couchbase Lite iOS.
Couchbase Lite databases are able to sync with each other via Sync Gateway backed by Couchbase Server.
Other ways to setup replication:
Download and run the GrocerySync and TodoLite demo applications.
Create your own Hello World Couchbase Lite via the Getting Started guide. (warning: these Getting Started guide correspond to the 1.0.0 release of Couchbase Lite, so you may run into issues with later releases.)
Using Gradle is the easiest way to automate Couchbase Lite builds in your project.
Important note: Maven artifacts can only be included with gradle builds, since the mvn tool does not know how to resolve and build .aar
dependencies.
http://files.couchbase.com/maven2/
NOTE: From 1.1.0 releae, Couchbase Lite Android is also hosted on JCenter which is default maven repository for Android Studio.
Optional: In the project level build.gradle
file, specify maven repo URL.
repositories {
jcenter()
maven {
url "http://files.couchbase.com/maven2/"
}
}
In the application level build.gradle
file, add following in android
section
// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
In the application level build.gradle
file, add following in dependencies
section
compile 'com.couchbase.lite:couchbase-lite-android:{latest-version}'
In case of using couchbase lite 1.3.1
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.couchbase.lite:couchbase-lite-android:1.3.1'
}
Where ${latest_version} should be replaced by something that looks like 1.1.1
. To find the latest version, check our Maven Repo directly and look for the latest version, ignoring anything that has a dash after it. (Eg, ignore items like 1.0.3-239
because they aren't official releases).
Maven repo URL: http://files.couchbase.com/maven2/
compile 'com.couchbase.lite:couchbase-lite-android:0.0.0-517'
While 0.0.0-517
was the latest build at the time of writing, it's probably out of date by the time you are reading this. To get the latest build number (eg, the "517" part of the version above), see our Maven Repo and look for the highest numbered version that starts with 0.0.0-
and is later than 0.0.0-517
Here is a complete gradle file that uses this maven artifact.
For Eclipse and Phonegap users, here are links to the zip file which includes the jars:
If you just want the pre-built binaries, see instructions above. The instructions that follow explain how to build Couchbase Lite from source.
These are known working versions. Other versions might be compatible (eg, later versions are likely to be compatible)
Couchbase Lite Version | Android Studio Version ------------- | ------------- 1.0.0 | Android Studio 0.5.7 1.0.1 | Android Studio 0.5.7 1.0.2 | Android Studio 0.8.2 1.0.3.x | Android Studio 0.8.2 - 0.8.9 1.0.4 | Android Studio 1.0 Master | Android Studio 1.0
Under Tools / Android / Android SDK Manager make sure "Extras/Google Repository" and "Extras/Android Support Repository" are installed.
Use Git to clone the Couchbase Lite repository to your local disk:
$ git clone git://github.com/couchbase/couchbase-lite-android.git
$ cd couchbase-lite-android
$ git submodule update --init --recursive
cp settings.gradle.example settings.gradle
Note: settings.gradle cannot be checked in directly due to Android Studio issue #65915
You should be able to import the project directly into Android Studio:
Caveat: when importing, you may see Wrong offset: 290. Should be in range: 0, 230, but after that you should be able to click the menu bar item "Sync Project with Gradle files" and the project should work.
See Running unit tests for couchbase lite android
If you've checked out this project directly, you might notice there is nothing to run. That is correct, as this project is a library.
If you want to run something (aside from the tests), you should get one of the sample apps listed below.
local.properties
file, configure Android Studio SDK location
cp local.properties.example local.properties
local.properties
according to your SDK installation directory$ ./gradlew assemble
$ ./gradlew connectedAndroidTest
$ ./gradlew build