Couchbase-Lite-Android


Source link: https://github.com/couchbase/couchbase-lite-android

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.

Architecture

Couchbase Lite databases are able to sync with each other via Sync Gateway backed by Couchbase Server.

Other ways to setup replication:

  • No replication -- just local data store.
  • Peer-to-peer replication between Couchbase Lite instances.
  • Replication to multiple Sync Gateway instances rather than a single Sync Gateway.
  • Etc ..

Documentation Overview

Getting started with Couchbase Lite

  • 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.)

Adding Couchbase Lite to your Gradle project

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.

Using latest official release

Optional: Maven repo URL: 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 and MavenCentral.

Optional: In the project level build.gradle file, specify maven repo URL.

repositories {

  jcenter()
  maven {

url "http://files.couchbase.com/maven2/"
  
}
 
}
 
Workaround for "duplicate files during packaging of APK" issue

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' 
}

  
Set couchbase-lite-android as dependency

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

dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:25.3.1'
  compile 'com.couchbase.lite:couchbase-lite-android:1.4.0' 
}
 

Where ${ latest_version } should be replaced by something that looks like 1.4.0. 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.4-46 because they aren't official releases).

Using master branch version (bleeding edge)

Maven repo URL: http://files.couchbase.com/maven2/

compile 'com.couchbase.lite:couchbase-lite-android:1.4-46' 

While 1.4-46 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 "46" part of the version above), see our Maven Repo and look for the highest numbered version that starts with 1.4- and is later than 1.4-46

Here is a complete gradle file that uses this maven artifact.

Zipfile that includes jars

For Eclipse and Phonegap users, here are links to the zip file which includes the jars:

Building Couchbase Lite via Android Studio

If you just want the pre-built binaries, see instructions above. The instructions that follow explain how to build Couchbase Lite from source.

Android Studio compatibility table

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.3.1 Android Studio 2.2.3
1.4.0 Android Studio 2.2.3
Master Android Studio 2.2.3

Prerequisites

  • Download Android Studio.

  • Under Tools / Android / Android SDK Manager make sure "Extras/Google Repository" and "Extras/Android Support Repository" are installed.

Clone the git repository

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 

Importing Project into Android Studio

You should be able to import the project directly into Android Studio:

  • Start Android Studio
  • Choose File / Import Project and choose the settings.gradle file in the couchbase-lite-android directory you cloned earlier. (Note: if you are on the welcome screen, choose "Import Non-Android Studio Project)
  • Hit Finish and wait for all tasks to finish (may take a while)

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.

Running tests in Android Studio

See Running unit tests for couchbase lite android

Running project in Android Studio

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.

Building Couchbase Lite on command line via gradle

  • Clone the git repository
    • See details above
  • Enable settings.gradle file
    • See details above
  • If you don't already have a local.properties file, configure Android Studio SDK location
    • cp local.properties.example local.properties
    • Customize local.properties according to your SDK installation directory
  • Compile (assemble)
    • $ ./gradlew assemble
  • Test
    • $ ./gradlew connectedAndroidTest
  • Build (compile & test)
    • $ ./gradlew build

Example Apps

System Requirements

  • Android 4.1.x Jelly Bean (API level 16) and above.

Limitations

  • Attachments are limited to 20MB if using Sync Gateway

Getting Help

Credits

Credits

License

  • Apache License 2.0

Resources

Urdu keyboard for android.

Messenger App showing various implementations of Android SMS apis.

Multi Line Radio Group is a Radio Group layout to show radio buttons in more than one line.

Riffsy RecyclerView MVP Grid Example using Dagger 2, Retrofit 2, RxJava 2 and Butterknife with Junit and Espresso tests.

This library allows to use hamburger to arrow animation for navigation in app.

A general purpose android UI library to show a user show menu in accordance of Floating action button with modern way of material design guidelines.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes