I’m very new to MOE and have gone through the getting started guide. I would like to learn a NoSQL database since I’ve never used one before and have decided on Couchbase Lite since it is a local database that is good for offline use.
I read the articles in the MOE docs under “Creating a Database App” that shows how to add SQLLite to your app, but I am a little confused with how to proceed with Couchbase Lite.
Seems Couchbase has native library so in this case I believe you can’t directly add Couchbase to a shared module. You may need to add iOS version to iOS module and create java bindings using natJ, add android version to your android app module, then add an abstract layer so you could put your database logic into a shared module.
Thanks for the reply. So with the plain Java version of Couchbase Lite, would I add that to the shared project between iOS and Android?
Also, you mention compiling their native code and JNI bindings for iOS, if the plain Java version of Couchbase Lite is added to the shared project will the compilation of the native code and JNI bindings automatically happen when I compile the project? Or is there a separate step I need to do?
for Android, you can add the Android library to your Android module. For iOS, you will need a separate step to build the necessary JNI library for iOS, and copy it to your iOS app. When both platforms have the necessary libraries, you will be able to use the CouchBase Java API from your common module.
Note: you will need to add a CouchBase dependency to the common module, so your IDE knows about these APIs, and then make sure that these dependencies are not transitively included in either Android or iOS, because those modules will already have these dependencies.
no, that topic is about using the Objective-C API of Realm from Java through our Nat/J library. It will work, but you will end up with separate APIs for your database, depending on the platform, and you will need to implement an abstraction layer yourself.
I can’t give you a step-by-step guide on how to compile the JNI library for CouchBase for iOS, because I don’t know the CouchBase project’s build system. But if you do that, you will have a single Java API for CouchBase, that you can use from Android and iOS as well.
We plan to prepare a tutorial on how to do this (and also Realm), but I can’t give you an exact timeline.
If you need this solution quicker, and it is an option for you, we at Migeran provide also commercial consulting and development services around MOE.