couchbaselabs / TouchDB-Android

CouchDB-compatible mobile database; Android version
239 stars 60 forks source link

Crash on x86 emulator when couchapp pushing to listener #64

Closed zenitraM closed 11 years ago

zenitraM commented 12 years ago

While doing a simple "couchapp push" on the emulator (4.0.3 image, on x86 platform, 512mb SDcard and RAM), it fails with:

W/dalvikvm( 1453): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/couchbase/touchdb/TDCollateJSON;
E/TDDatabase( 1453): Exception in TDRouter
E/TDDatabase( 1453): java.lang.reflect.InvocationTargetException
E/TDDatabase( 1453):    at java.lang.reflect.Method.invokeNative(Native Method)
E/TDDatabase( 1453):    at java.lang.reflect.Method.invoke(Method.java:511)
E/TDDatabase( 1453):    at com.couchbase.touchdb.router.TDRouter.start(TDRouter.java:390)
E/TDDatabase( 1453):    at com.couchbase.touchdb.listener.TDHTTPServlet.service(TDHTTPServlet.java:108)
E/TDDatabase( 1453):    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
E/TDDatabase( 1453):    at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2347)
E/TDDatabase( 1453):    at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2266)
E/TDDatabase( 1453):    at Acme.Serve.Serve$ServeConnection.run(Serve.java:2056)
E/TDDatabase( 1453):    at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1223)
E/TDDatabase( 1453):    at java.lang.Thread.run(Thread.java:856)
E/TDDatabase( 1453): Caused by: java.lang.ExceptionInInitializerError
E/TDDatabase( 1453):    at com.couchbase.touchdb.TDDatabase.open(TDDatabase.java:222)
E/TDDatabase( 1453):    at com.couchbase.touchdb.router.TDRouter.do_PUT_Database(TDRouter.java:654)
E/TDDatabase( 1453):    ... 10 more
E/TDDatabase( 1453): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load com_couchbase_touchdb_TDCollateJSON: findLibrary returned null
E/TDDatabase( 1453):    at java.lang.Runtime.loadLibrary(Runtime.java:365)
E/TDDatabase( 1453):    at java.lang.System.loadLibrary(System.java:535)
E/TDDatabase( 1453):    at com.couchbase.touchdb.TDCollateJSON.<clinit>(TDCollateJSON.java:27)
E/TDDatabase( 1453):    ... 12 more
I/ActivityManager(  877): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 877

This doesn't seem to happen on my real devices.

zenitraM commented 12 years ago

..and this seems to be due to using binary libraries:

 $ find . -name "*.so"
./TouchDB-Android/TouchDB-Android/obj/local/armeabi/libcom_couchbase_touchdb_TDCollateJSON.so
./TouchDB-Android/TouchDB-Android/libs/armeabi/libcom_couchbase_touchdb_TDCollateJSON.so

compiled for ARM. This makes it not work on x86 or MIPS-based Android platforms, which is not an issue for my project but could be an issue for Play Store-purposed apps.

mschoch commented 12 years ago

Added support for x86 and MIPS platforms.

https://github.com/couchbaselabs/TouchDB-Android/commit/0a6f8267223ea3c8127b4b1c07a8c7ec52aac85c

I only tested that ARM still worked after these changes. If you can try this in the x86 emulator that would be great.