Giter Club home page Giter Club logo

grocerysync-android's Introduction

Grocery Sync for Couchbase Lite Android

This is a simple example of using the Couchbase Lite Android mobile database framework.

The "use case" is a shared grocery list where all devices using the application would see a mirror of the grocery list. Any changes will automatically background sync with a Sync Gateway running in the cloud. (bi-directional)

Prequisites

  • Install Android Studio version 0.1.3 or later with Android Support Repository and Google Repository.
  • (optional) Install Sync Gateway to use the sync feature.

Getting the code

$ git clone [email protected]:couchbaselabs/GrocerySync-Android.git

Note: it is important to leave the directory name as the default, otherwise it could confuse the Android Studio IDE

Configure Android SDK location

Gradle (the build system used by Studio) needs to know where your Android SDK is, otherwise it won't be able to build anything.

  • First the local.properties file must be created so that Android knows where your SDK is: $ cp local.properties.example local.properties.
  • If you are on OSX and installed Android Studio to the default location, you should be ok with the defaults in local.properties
  • Otherwise, open local.properties and make sure it points to the Android SDK on your system. Change the path as needed.

Import the project in Android Studio

  • Choose File / Import project
  • Check "Auto-import"
  • Leave "Use default gradle wrapper"
  • After your open the project, it should look like this, and the imports should be ok, as shown here

Enable Android Support Repository and Google Repository

Open the Android SDK from Android Studio (Tools->Android->SDK Manager) and make sure that the Android Support Repository and Google Repository items are installed.

(This may be enabled by default, but it's good to double check since it's a required dependency in order to get the android support library: 'com.android.support:support-v4:13.0.0' )

Configuring a remote sync gateway (optional)

GrocerySync can be configured to do a two way sync all of its data to a Sync Gateway instance, so it needs a valid URL.

  • Configure the hardcoded DATABASE_URL in the MainActivity.java file to the URL of your Sync Gateway instance. (there is also a value in the Settings that can be used, which will override the hardcoded default)
  • Create a DB named grocery-test on the Sync Gateway instance.

Run the app via Android Studio

  • Run it using the "play" or "debug" buttons in the UI

Run via Gradle

  • Run the android emulator
  • Run ./gradlew clean && ./gradlew installDebug
  • Switch to the emulator and you should have a new app called GrocerySync-Android
  • Tap it to open the app

Change the dependency from Maven -> Direct code dependency

By default, this project depends on the Couchbase Lite maven artifacts. However, it can also depend on the CBLite code directly, which is useful if you want to debug into the CBLIte code (or just browse the code).

See the build.gradle and settings.gradle files for instructions on how to do this.

Where to go from here: creating your own Couchbase-Lite app

See the Getting Started Guide.

Deviations from the iOS version

Android typically uses a long-click to trigger additional action, as opposed to swipe-to-delete, so this convention was followed.

Known Issues

We currently do not handle the Sync URL changing at runtime (if you change it you have to restart the app)

grocerysync-android's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.