I'm updating my Android app to use Zumero to handle data sync. Each user will get their own dbfile on the server, as well as their own internal auth account. However, I can't get zumero_internal_auth_add_user
to work in Android.
I invoke the function with SQLiteDatabase.execSQL
, generating SQL of the form:
SELECT zumero_internal_auth_add_user(
'<ZUMERO URL>’,
'test1_users',
zumero_internal_auth_scheme('zumero_users_admin'),
'admin',
'<ADMIN_PWD>',
'username',
'pwd'
);
This causes a SQLiteException with error code 100 (unknown error). The logs show that the operation apparently succeeded (http status code is 204: No Content), but the Zumero library did not recognize this (maybe it's only expecting 200?) and throws an exception.
06-04 23:13:42.247: V/Zumero(15442): execute for query: SELECT zumero_internal_auth_add_user(?, ?, zumero_internal_auth_scheme('zumero_users_admin'), ?, ?, ?, ?)
06-04 23:13:42.247: V/ZUMERO(15442): Network call started.
06-04 23:13:42.247: V/ZUMERO(15442): got JNI env.
06-04 23:13:42.247: V/ZUMERO(15442): Looked up java classes.
06-04 23:13:42.247: V/ZUMERO(15442): Initiating Network connection.
06-04 23:13:42.302: D/dalvikvm(15442): GC_CONCURRENT freed 132K, 2% free 9120K/9280K, paused 3ms+5ms, total 25ms
06-04 23:13:42.825: V/ZUMERO(15442): HTTP connection finished.
06-04 23:13:42.825: V/ZUMERO(15442): HTTP status code: 204.
06-04 23:13:42.825: V/ZUMERO(15442): HTTP error code: 0.
06-04 23:13:42.825: V/ZUMERO(15442): Network connection completed successfully.
06-04 23:13:42.825: W/dalvikvm(15442): threadid=13: thread exiting with uncaught exception (group=0x40b4d930)
06-04 23:13:42.833: E/AndroidRuntime(15442): FATAL EXCEPTION: AsyncTask #1
06-04 23:13:42.833: E/AndroidRuntime(15442): java.lang.RuntimeException: An error occured while executing doInBackground()
06-04 23:13:42.833: E/AndroidRuntime(15442): at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-04 23:13:42.833: E/AndroidRuntime(15442): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-04 23:13:42.833: E/AndroidRuntime(15442): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-04 23:13:42.833: E/AndroidRuntime(15442): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-04 23:13:42.833: E/AndroidRuntime(15442): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-04 23:13:42.833: E/AndroidRuntime(15442): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-04 23:13:42.833: E/AndroidRuntime(15442): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-04 23:13:42.833: E/AndroidRuntime(15442): at java.lang.Thread.run(Thread.java:856)
06-04 23:13:42.833: E/AndroidRuntime(15442): Caused by: com.zumero.sqlite.SQLiteException: error code 100: unknown error
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.zumero.sqlite.SQLiteStatement.native_execute(Native Method)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.zumero.sqlite.SQLiteStatement.execute(SQLiteStatement.java:63)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.zumero.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1810)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.example.people.ZumeroBackend.addUser(ZumeroBackend.java:31)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.example.people.PeopleProvider.insert(PeopleProvider.java:150)
06-04 23:18:16.575: E/AndroidRuntime(15713): at android.content.ContentProvider$Transport.insert(ContentProvider.java:201)
06-04 23:18:16.575: E/AndroidRuntime(15713): at android.content.ContentResolver.insert(ContentResolver.java:866)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.example.people.PeopleActivity.setAccount(PeopleActivity.java:265)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.example.people.PeopleActivity.access$3(PeopleActivity.java:262)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.example.people.PeopleActivity$4.doInBackground(PeopleActivity.java:250)
06-04 23:18:16.575: E/AndroidRuntime(15713): at com.example.people.PeopleActivity$4.doInBackground(PeopleActivity.java:1)
06-04 23:18:16.575: E/AndroidRuntime(15713): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-04 23:18:16.575: E/AndroidRuntime(15713): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-04 23:18:16.575: E/AndroidRuntime(15713): ... 4 more
If I try to add the same user again, the operation fails with zumero:unique_constraint_violation
, confirming my suspicion that the original call succeeded. I tried running zumero_internal_auth_add_user
in a SQLite shell (on Windows) and it worked fine, suggesting that the problem is specific to the Android lib. I pulled the zumero_log dbfile and found that zumero_internal_auth_add_user
returns a 204 in both cases (from Android and SQLite shell).
Am I doing something wrong, or is there is a bug in the Zumero Android library?