Android create database failing with 404


#1

I am building an app using Cordova and the couchbase lite plugin. It works flawlessly on iOS but when testing for the first time on Android (Galaxy S4 running 4.4.2) it fails to create the database.

getURL is working correctly although the URL seems odd (in comparison to iOS anyway).
http://2b78a9d0-e090-4355-81ff-ae015fa503f0:8c72c2d4-8531-480c-8bdd-fc99b0204a63@localhost:5984/

Sending a GET via the REST API to the database works and correctly notes that the database does not exist. But attempting to create the database results in a 404 with no response or error text.

Couchbase Plugin v1.1.0 (downloaded today)

I am at a loss as to what the problem is because there is no information provided. Is there some place to get additional logging to determine the root cause? I don’t know if this is due to the latest plugin since I have not tested before upgrading today on Android.


#2

Unfortunately, as I keep learning more about what might be causing the problem it is getting worse as the errors aren’t even consistent across different Android devices.

When testing on the Samsung Galaxy S4, I am seeing the following errors in the log files:

E/DatabaseUtils(  691): Writing exception to parcel
E/DatabaseUtils(  691): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
E/DatabaseUtils(  691):     at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15034)
E/DatabaseUtils(  691):     at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2488)
E/DatabaseUtils(  691):     at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:688)
E/DatabaseUtils(  691):     at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
E/DatabaseUtils(  691):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
E/DatabaseUtils(  691):     at android.os.Binder.execTransact(Binder.java:404)
E/DatabaseUtils(  691):     at dalvik.system.NativeStart.run(Native Method)
W/ActivityManager(  691): Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL

Based on further reading, this permission is a OEM level permission and I cannot ever get it. It seems to be related to some SQLite permission issue on some devices.

So, I tried it on another device, the Motorola Atrix to see how that might work and whether this is just a Samsung Galaxy S4 issue.

Here is the error line that I see in the logs when running on that device:

06-28 12:13:01.545  7715  7729 W IceCreamCordovaWebViewClient: URL blocked by whitelist: http://localhost:5984/scoremoredb

So, I added a permission to my whitelist for the EXACT url described there which gives me the following error instead:

06-28 12:09:36.055  7410  7435 E chromium: external/chromium/net/disk_cache/stat_hub.cc:216: [0628/120936:ERROR:stat_hub.cc(216)] StatHub::Init - App com.scoremorebaseball.scoremore isn't supported.
06-28 12:09:36.055  7410  7435 V chromium: external/chromium/net/disk_cache/hostres_plugin_bridge.cc:73: [0628/120936:INFO:hostres_plugin_bridge.cc(73)] netstack: Failed to find symbols in plugin: libdnshostprio.so
06-28 12:09:36.055  7410  7435 E chromium: external/chromium/net/disk_cache/stat_hub.cc:216: [0628/120936:ERROR:stat_hub.cc(216)] StatHub::Init - App com.scoremorebaseball.scoremore isn't supported.
0

I am at a complete loss as to how to proceed without getting yet another Android device to test on as all possible solutions I am reading about on the internet are not working for either of these devices.

Update: I have also found a way to downgrade to the 1.0.4 version of the couchbase lite cordova plugin and that had no impact. So, this doesn’t appear to be related to the upgrade to 1.1.


#3

Hi @mkirkup,

On iOS, the PhoneGap plugin uses the internal url which is only accessible within the sandboxed application for security reasons.
It’s different on Android, basic auth is used to enforce security. That’s why the urls look different on each platform.

Can you provide the exact command to create the db if you’re using curl?

You can refer to the TodoLite-Ionic app for more examples of http requests against the cbl listener.

James