Testing Android-Couchbase Installation Package

229 views
Skip to first unread message

Marty Schoch

unread,
Aug 25, 2011, 11:27:23 PM8/25/11
to mobile-c...@googlegroups.com
In our ongoing effort to make it easier for developers to incorporate
Mobile Couchbase into their Android projects, we have a new package
and instructions for developers to test. If the feedback is positive,
this may replace the other scripts and become the primary installation
method.

Prerequisites:

Android SDK
Eclipse ADT

Instructions:

1. Create a new Android project or select an existing project.
2. Download Couchbase.zip and couchbase.xml into the top-level of the project:

https://github.com/downloads/mschoch/Android-Couchbase/Couchbase.zip
https://github.com/downloads/mschoch/Android-Couchbase/couchbase.xml

3. Right-click on couchbase.xml and select Run As > Ant Build
4. Refresh your project

You can now add Couchbase to your project using code like:

private final ICouchClient mCallback = new ICouchClient.Stub() {
@Override
public void couchStarted(String host, int port) {}

@Override
public void installing(int completed, int total) {}

@Override
public void exit(String error) {}
};

public void startMyApplication() {
CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mCallback);
couchServiceConnection = couch.startCouchbase();
}

We think this is the easiest way to get Mobile Couchbase into your
Android project yet. But we want to hear your feedback!

marty

Dale Harvey

unread,
Aug 26, 2011, 3:04:07 PM8/26/11
to mobile-c...@googlegroups.com
Ok I have tested this out and it works great, awesome job

It is by far the easiest way we have had so far,

one small problem I had was that when running the build first time, I actually used the wrong Couchbase.zip which failed the build, that wasnt so much a problem however when I corrected it, it was impossible to run the build again, after a clean build and a refresh (various times) the couchbase.xml still had a red mark with (couchbase.xml not found) this isnt a problem with the script but should probably be in a faq somewhere

Updates I dont think would be a problem, can ant handle wildcard filepaths? I am thinking Couchbase.zip should probably be git sha'd just to keep things obvious, it means couchbase.xml needs to know which version is installed and be able to clean up old files

Cheers
Dale

Alexander Gabriel

unread,
Aug 26, 2011, 3:46:25 PM8/26/11
to mobile-c...@googlegroups.com
Sounds great.
But your instructions are not precise or extensive enough for an Android dummy like me.
"You can now add Couchbase to your project using code like:"
What do you mean with "your project"? Would that be the activity.java file?
And how would I manage to get my specific couchapp started?
Thanks for help.
Alex




2011/8/26 Marty Schoch <marty....@gmail.com>

Marty Schoch

unread,
Aug 26, 2011, 3:48:38 PM8/26/11
to mobile-c...@googlegroups.com
Yeah I've seen the persistent red mark show up because we include a
file at run-time and have references to tasks that eclipse doesn't
know about. Even the standard Android ant build files have this
problem.

Certainly we can do a better job of error reporting when the zip file
didn't contain what we expected.

I'm not opposed to adding the sha to the filename, but I was hoping to
keep the couchbase.xml generic enough that on upgrade the user only
has to replace the zip file. Chris had even thrown out the idea that
the script could (when asked) check the web to see if there was a
newer zip package available. We might be able to roll all this
together.

marty

Marty Schoch

unread,
Aug 26, 2011, 3:56:21 PM8/26/11
to mobile-c...@googlegroups.com
I agree, the instructions for that step are not very clear and make a
lot of assumptions. I'll see if I can make that more clear in the
next version.

Getting a particular couchapp started may go beyond the basic getting
started instructions though, as you'll most likely have other
decisions to make, such as whether you'll be using Ektorp or not. But
yes, there should be a document describing how to do this.

marty

Alexander Gabriel

unread,
Aug 26, 2011, 4:03:00 PM8/26/11
to mobile-c...@googlegroups.com
looking forward to those instructions. Ektorp is new to me.
Thanks for the great work

J Chris Anderson

unread,
Aug 26, 2011, 4:04:50 PM8/26/11
to mobile-c...@googlegroups.com
For what it's worth, we've just upgraded the iOS page to be more
specific about how to get start with iOS. Expect this sort of thing to
show up for Android in the next few weeks.

http://www.couchbase.org/get/couchbase-mobile-for-ios/current

Chris

Alexander Gabriel

unread,
Aug 26, 2011, 4:08:12 PM8/26/11
to mobile-c...@googlegroups.com
great, so I'll try that first
Thanks!
Alex



2011/8/26 J Chris Anderson <jch...@couchbase.com>

Dale Harvey

unread,
Aug 26, 2011, 4:29:13 PM8/26/11
to mobile-c...@googlegroups.com
Chris are those the right instructions? I only see " (See CouchbaseEmbeddedServer.h, and see EmptyAppDelegate.m for an example of how to call it.)"

Alexander, yeh this will be fleshed out but you had the right idea, its just that code added to the activity, here is the ultra minimal example

http://pastebin.me/45120524e85f5981a813eef6ec12fe7b

J. Chris Anderson

unread,
Aug 29, 2011, 8:21:53 PM8/29/11
to mobile-c...@googlegroups.com
Thanks Dale I've updated them. Next up is the Android page...

Chris

groovinfingers

unread,
Aug 30, 2011, 10:29:37 AM8/30/11
to mobile-c...@googlegroups.com
Hola, folks.  My company is evaluating this product. The iOS version worked out of the box. The Android experience has been very frustrating.

** System being used **

Mac OS X version 10.6.8. Eclipse 3.6.1.


** Steps to reproduce problem **

08-29 08:44:00.777: ERROR/AndroidRuntime(21797): Caused by: java.lang.UnsatisfiedLinkError: Library com_google_ase_Exec not found

  • I then posted the information above to the URL below at which time a helpful person directed me to this GGroup.

https://github.com/couchbase/Android-Couchbase/issues/1

  • Next, I downloaded the zip and xml file specified earlier in this discussion and added them to my Android project.  I also removed from my Android project all references to the LibCouch project.  
  • After doing this, the couchbase.xml file contains an error.  The error says the following.  

Target couchbase-internal.update-libaries does not exist in this project couchbase.xml /CouchApp line 9 Ant Buildfile Problem


Would someone mind pointing me in the right direction, please?

Thanks for reading this far.

gf


Marty Schoch

unread,
Aug 30, 2011, 10:58:32 AM8/30/11
to mobile-c...@googlegroups.com
Hi gf,

We'll definitely help get you up and running.

Although highly confusing, it's actually normal to see the message


"Target couchbase-internal.update-libaries does not exist in this

project " if you open the couchbase.xml file. This has to do with us
referencing a target that is included at runtime and not visible to
eclipse. However, if you right click on that file and select Run As >
Ant Build it should run successfully.

Can you give that a try?

marty

groovinfingers

unread,
Aug 31, 2011, 10:28:13 AM8/31/11
to mobile-c...@googlegroups.com
Thanks, Marty.  I appreciate you offering to help.

Yep - I initially had attempted to run the ant script; I apologize for not posting the results.  Here are the results.

Buildfile: /Users/[omitted]/Development/workspace/CouchApp/couchbase.xml

BUILD FAILED

/Users/[omitted]/Development/workspace/CouchApp/couchbase.xml:3: Problem: failed to create task or type include

Cause: The name is undefined.

Action: Check the spelling.

Action: Check that any custom tasks/types have been declared.

Action: Check that any <presetdef>/<macrodef> declarations have taken place.

Total time: 46 milliseconds


gf


Marty Schoch

unread,
Aug 31, 2011, 10:51:56 AM8/31/11
to mobile-c...@googlegroups.com
That error message helps a lot. It cannot find the task "include".
According to the docs this was introduced in ant 1.8, so it looks like
you may have an earlier version of ant. You should be able to check
this by running:

ant -version

That said, we have an updated version of the zip/script package that I
hope will be posted today. One of the changes in this script is we
changed from using "include" to "import". Hopefully your version of
ant understands the import task (though we may find other issues, I
have not tested with anything less than 1.8)

Once the files are online we'll post a message to this group. Your
assistance in testing these scripts will be a big help to the
community.

Also, it would be great if you could let us know your Eclipse version
as well as your Ant version. We'll at least want to document which
versions we know work.

Thanks,
marty

Marty Schoch

unread,
Aug 31, 2011, 11:19:22 AM8/31/11
to mobile-c...@googlegroups.com
I just tested the upcoming package with Eclipse 3.6 which include Ant
1.7.1 and I ran into additional problems. If you want to get up and
running quickly, I would recommend Eclipse 3.7 which includes Ant
1.8.2.

I'll take a look at how much effort there is in supporting Ant 1.7.x.

marty

mikeymckay

unread,
Aug 31, 2011, 3:44:55 PM8/31/11
to Mobile Couchbase
I'm with Alexander on this one.

I've been trying to develop a couchdb based app for a few months now,
and it has been a real moving target.

Should I assume that using Dale's "CouchApp" in the market is no
longer recommended?

I have a working application, implemented as a couchapp - so
everything is html, js and REST calls to a couch. One of the main
reasons I am using CouchDB is to avoid the complexity of writing/
maintaining/collaborating on a java app. Now I need to deploy it to
many devices.

I see two ways to get what I need:

1) Install couchapp so that it runs on start and in the background
(recommendations?). Replicate from a couchdb into the android couch to
install my couchapp. Create a bookmark to the local app.
2) Use phonegap to package a couchdb library and my app.

I have been working steadily towards option 1, but am now worried
(freaked out) that it is going to disappear. If we have to use option
2, it would certainly save us massive amounts of headache if we could
just run "couchapp phonegap" and it would package everything up and
compile it into an APK. Is that asking too much?

@mikeymckay

On Aug 26, 3:46 pm, Alexander Gabriel <a...@barbalex.ch> wrote:
> Sounds great.
> But your instructions are not precise or extensive enough for an Android
> dummy like me.
> "You can now add Couchbase to your project using code like:"
> What do you mean with "your project"? Would that be the activity.java file?
> And how would I manage to get my specific couchapp started?
> Thanks for help.
> Alex
>
> 2011/8/26 Marty Schoch <marty.sch...@gmail.com>

Dale Harvey

unread,
Aug 31, 2011, 4:03:48 PM8/31/11
to mobile-c...@googlegroups.com
Hey Mike

The "CouchApp" app on the market has been renamed to "MobileFuton", it will be available in the market indefinitely

https://market.android.com/details?id=com.daleharvey.mobilefuton

Your option of building an application against this one is exactly why I built it, however I built it as a development tool for android apps and not a deployment one.

For the final deployment of applications, its recommended you follow these instructions to build a standalone application that includes the code to your couchapp, that way your uses dont need to do any bookmarking or replication, and you dont need to worry about my app dissapearing (or more likely being updated in incompatible ways)

Recently the android toolchain has undergone a quite a few changes, however this is all in the aim of reducing the complexity of building a standalone app as much as possible, we are now at the point where things should start settling down and we can completely flesh out the documentation and make things as clear as possible

Cheers
Dale

P.S it should be eventually possible to have a single "couchappdeploy MyApp.apk", and some of the work being done here will allow that to happen, however for the time being I will update my MobileFuton app which can be used to deploy any couchapp on to android, I will email the list when thats done.

Mike McKay

unread,
Aug 31, 2011, 4:56:50 PM8/31/11
to mobile-c...@googlegroups.com
Thanks Dale,

For the final deployment of applications, its recommended you follow these instructions to build a standalone application that includes the code to your couchapp, that way your uses dont need to do any bookmarking or replication, and you dont need to worry about my app dissapearing (or more likely being updated in incompatible ways)

Looking at the instructions and the sample EmptyApp (https://github.com/couchbase/Android-EmptyApp) it is not clear to me what interface couchbase is providing and how one might configure it. Specifically, once I have run:

couch.startCouchbase()

How do I communicate with it? Is it on localhost at port 5984? If I package an html file (a la Phonegap) will I be able to pull resources from CouchDB or will that be cross domain (cross port anyway)? Instead of packaging an html file, can I just replicate my couchapp into it and open a URL that points to a design document? 

public void postInstall() { //I am totally making this code up CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mCallback); couch.replicate("http://mikeymckay.iriscouch.com/egra", "egra"); } public void startCouchbase() { CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mCallback); couchServiceConnection = couch.startCouchbase(); // Wouldn't this be great? Browser.loadURL("http://localhost:5984/egra/_design/app/index.html") }
That would be awesome. But it could be even better. Imagine a web page. You go there, point it to a couchapp URL out in the cloud "http://mikeymckay.iriscouch.com/egra/_design/app/index.html". After clicking a magic button that says "Create android app" it returns an Android APK file ready to deploy anywhere. I can dream, can't I?

Anyway, I now have mobilefuton and it looks like it has come a long way - good work. Keep it up guys!

Mike

groovinfingers

unread,
Sep 1, 2011, 2:05:54 PM9/1/11
to mobile-c...@googlegroups.com
Marty - again, thanks.

To answer your question, my version of Eclipse (3.6.1) ships with Ant 1.7.1.  It looks like your tests exposed some problems - possibly the same that I encountered.  Nonetheless, I wanted to make sure I answered your question.  

I'd personally love to switch over to Eclipse 3.7 but from a development-organization point-of-view, I would need to migrate a team of developers over to the new version which means that this effort would need to be coordinated so that our project timelines can remain unaffected.  
It would be ideal if we could remain on Eclipse 3.6 but I am not opposed to making the pitch that we should consider an upgrade to 3.7.  From probably a naive point of view, I personally think there is value in supporting Eclipse 3.6 as doing so will make it easier for shops that are using this version to more easily use the Couchbase product.  An easy installation of a product is always a welcomed treat to a busy developer. heh heh  

I actually have Ant 1.8.2 installed on my Mac and it's in my system path.  As a work-around, could I open up bash and nav to the root of my project folder and then issue the command to run the script?  What I don't know is if the script needs to be issued from the context of Eclipse.

gf

groovinfingers

unread,
Sep 1, 2011, 2:10:11 PM9/1/11
to mobile-c...@googlegroups.com
Forgot to say that yes - I'd be happy to offer my time with testing the new version.

gf

Marty Schoch

unread,
Sep 1, 2011, 5:24:57 PM9/1/11
to mobile-c...@googlegroups.com
We've updated the Android package to support using Ant 1.7.x and I've
tested it with Eclipse 3.6.1.

As Chris said in his announcement, the latest packages and
instructions can be found here:

http://www.couchbase.org/get/couchbase-mobile-for-android/current

Thanks again to everyone testing these packages.

marty

Reply all
Reply to author
Forward
0 new messages