Couchdb on Android with API 2.0

I am working on an Android project, the idea is simple: I just need to record the time the button was clicked. This part is flat and simple.

The problem is that I need to synchronize the data in real time (or at least with a very acceptable delay <= 5s). Plus, perhaps the device may lose the connection, so we also need this application to work offline.

To achieve this, I need to replicate the data, and couchdb seems to offer this.

So, I started testing a few examples:

But none of them work with these instructions . I mean that it works by making the apk file, the installation is successful, but when the application launches it, it works and does nothing.

I understand that CouchDB on Android works as follows:

  • Install the CouchDB service, so several applications can use this service.
  • My Android application should use the API to work with this CouchDB service by doing POST, GET, PUT, etc.

My question is:

  • How to make work on examples above with API 2.0?

Update:

Possible link: https://groups.google.com/group/mobile-couchbase/browse_thread/thread/83816c0d0f1b050b

Update 2:

It seems that the problem in the processor version of all the tablets that I have is armv5.

Associated with the error: http://www.couchbase.org/issues/browse/CBMA-13

I have not tested arm7v cpu yet, but I will do it in a couple of hours.

Update 3:

I tested the application twice, but still not working with (ARM) armeabi-7va

Update 4:

I tested an example of a mobile futon on several devices:

  • arm5v: test failure (emulator and real device), application market and own assembly.
  • arm6v: test failure (real device), application market and native build.
  • arm7v: test failure (emulator), application market and own assembly.

So many ways have failed that I'm so upset. And even if I manage to run couchdb in arm5v, I will have to deal with these basic errors 1 2 :

+4
source share
1 answer

We use CouchDB on Android, as well as in a large project. These 2 errors were reported by me, and, unfortunately, they are still not fixed. However, workarounds for them:

CBMA-10: If you create the target database manually through HTTP PUT before starting replication, you do not need to create_target , and everything will be fine.

CBMA-3: If you want to start replication by invoking _replicate and the thread still blocks after canceling replication, you can cancel this request manually. Unfortunately, some versions of Android have an error, so calling httpRequest.abort() does not work (see http://code.google.com/p/android/issues/detail?id=7933 ). You can work around this by introducing a custom SocketFactory to access the socket used by the request and call shutdownInput() , which causes the request to abort. Another alternative would be to use a replicator database (see https://gist.github.com/832610 ). In this case, there is no blocking thread during replication, but you should poll the replicator database to see when replication is complete.

In addition to these problems, there are other problems when using the CouchDB replication mechanism on mobile platforms. The implementation has not yet been fully added to support the mobile scenario. Thus, replication hangs me, for example, if the network connection is unstable. In addition, there is a re-launch mechanism with exponential outflow, which is suitable for server installations, but not on mobile platforms where connection loss is a common occurrence. So, in general, you must carefully decide whether you want to use mobile CouchDB in this early state. Perhaps you should defer your decision until the first official release of GA (the guys from Couchbase announced that in December).

+3
source

Source: https://habr.com/ru/post/1380261/


All Articles