Question

I am working on a native CouchdDB app with android. Now just this week CouchOne released libcouch, described as "Library files needed to interact with CouchDB on Android": couchone_libcouch@Github

It is a basic app that installs CouchDB if the CouchDB service (that comes with CouchDB if it was installed previously) can't be bound to.

To be more precise, as I understand it: libcouch estimates CouchDb's presence on the device by trying to bind to a IPC Service from CouchDB and through that service wants communicate with CouchDB.

Please see the method "attemptLaunch()" at CouchAppLauncher.class for reviewing this:

public void attemptLaunch() {

    Log.i(TAG,"1.) called attemptLaunch");

Intent intent = new Intent(ICouchService.class.getName());
    Log.i(TAG,"1.a) setup Intent");

    Boolean canStart = bindService(intent, couchServiceConn,
            Context.BIND_AUTO_CREATE);

    Log.i(TAG,"1.b bound service. canStart: " + Boolean.toString(canStart));


    if (!canStart) {

        setContentView(R.layout.install_couchdb);

        TextView label = (TextView) findViewById(R.id.install_couchdb_text);
        Button btn = (Button) this.findViewById(R.id.install_couchdb_btn);

        String text = getString(R.string.app_name)
                + " requires Apache CouchDB to be installed.";
        label.setText(text);


        // Launching the market will fail on emulators
        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                launchMarket();
                finish();
            }
        });
    }
}

The question(s) I have about this are: libcouch never is able to "find" a previously installed CouchDB. It always attempts to install CouchDB from the market. This is because it never actually is able to bind to the CouchDBService. As I understand the purpose auf AIDL generated service interfaces, the actual service that intends to offer it's IPC to other applications should make use of AIDL. In this case the AIDL has been moved to the application that is trying to bind to the remote service, which is libcouch in this case.

Reviewing the commits the AIDL files have just been moved out of that repository to libcouch.

For complete linkage, here's the link to the Android CouchDB sources: github.com/couchone/libcouch-android

Now, I could be completely wrong in my findings, it could also be lincouch's Manifest that s missing something, but I am really looking forward to get some answers!

Was it helpful?

Solution

I replied in an email but to reiterate for anyone here.

The libcouch library is included into the core CouchDB application as well as to be used by client applications so the CouchDB Service does include those aidl files.

The reason you have probably been able to consume the service is that there have been 2 versions of CouchDB on the market, there was an old version without any service, and a new one (that has been invisible to 2.1 users). Tonight the Updated CouchDB app has been republished for 2.1 users and the old version removed.

The source code of CouchAppLauncher should help you see how to consume the service, I will also be publishing a tutorial shortly

Thanks Dale

OTHER TIPS

And just to be complete, I think Someone put out a very nice tutorial for couchapps on android:)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top