Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

FAQ Android

Traun Leyden edited this page Jun 5, 2013 · 14 revisions

Q: What are all these different sub-projects for?

A: TouchDB is designed to be modular, allowing the application developer to choose the pieces they need and distribute the smallest application possible.

  • TouchDB-Android - This is the core of TouchDB. It is required for all TouchDB applications.
  • TouchDB-Android-Ektorp - This is an adapter that allows you to use the Ektorp API to talk to TouchDB. This is the recommended way for building a native Android application. MOST native applications will use this module.
  • TouchDB-Android-JavaScript - This is a module which allows for compilation/execution of view map/reduce functions written in the JavaScript language. Native applications typically do not require this module as they will implement map/reduce functions in Java. This module enables CouchApp/TouchApp style applications which depend on JavaScript. Use of this module adds approximately 1MB to your application.
  • TouchDB-Android-Listener - This module allows you to start an HTTP server port connected to TouchDB. Native applications typically don't need this module unless they also wish to support peer-to-peer replication. The module is also useful for CouchApp/TouchApp style applications, and for running the original CouchDB test suite.
  • TouchDB-Android-TestApp - This module contains the unit tests and a test application which starts the listener on port 8888 and waits for requests.

Q: java.lang.NoClassDefFoundError: org.codehaus.jackson.map.ObjectMapper while running tests

A: In Eclipse go to: "Project" -> "Properties" -> "Java Build Properties" for the test app and each library. In the "Order and Export" tab I checked "Android Private Libraries" on my project. This should fix the class not found errors following upgrading to SDK 22. StackOverflow post.

Q: Why do I see this message when I build TouchDB-Android The method ... of type ... must override or implement a supertype method

A: Typically this happens when you're not using a 1.6 compiler. Check your Java Compiler settings in Eclipse and choose a 1.6 compiler.

Q: Why do I see these messages when I run my application [2012-05-15 15:27:32 - TouchDB-Android] Could not find TouchDB-Android.apk!

A: Remove the preset "Libary" from the projects and run each of them. Ecplipse will prompt an error message saying there was not found an "Launcher activity" but it has synced the android application package. Do not forget to set the library as library afterwards again or you will get another error message when using the packages for example with the TestApp

Q: Why do I see this message when I run my application java.lang.NoSuchMethodError: android.database.sqlite.SQLiteDatabase.insertWithOnConflict

A: This happens when you run with an SDK < 2.2. TouchDB-Android requires SDK 2.2 or newer.

Q: Why do I see a message like java.net.MalformedURLException: Unknown protocol: touchdb

A: When using the Ektorp adapter we need to install a URL handler for the touchdb protocol. This needs to be done early in your application life-cycle prior to using TouchDB or accessing any other URLs. Currently I recommend you place the following static initialization block in your application's main Activity:

{
    TDURLStreamHandlerFactory.registerSelfIgnoreError();
}

Q: Why do I see messages like Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (Acme.Serve.Main$1) that doesn't come with an associated EnclosingMethod attribute.

A: This has to do with the packaging of the HTTP Server library we're using in the Listener module. I think we can fix this by repackaging it properly in the future. For now it does not seem to cause any other problems and can be ignored.

Q: I see code defining views at runtime. Are views persisted in the database?

A: Because TouchDB defines views using native code, they must be provided to TouchDB at runtime. However, the results of the map function are stored and re-used. When registering your view with TouchDB they are given a name and version number. Views with the same name and version will reuse data already generated. So, when changing the implementation of your views it is important to bump the version number. See this for more information using TouchDB Views in EKtorp.

Q: I cloned the GrocerySync App from GitHub and got the project references updated. Am I supposed to see a splash screen that says "Starting Couchbase-Mobile"?

A: No. You cloned the master branch from github. Clone the touchdb branch instead.