Couchbase lite android test db directory can not be created.

112 views
Skip to first unread message

Erwan Koffi

unread,
May 19, 2015, 10:57:23 PM5/19/15
to mobile-c...@googlegroups.com
Hello,

I am currently trying to use couchbase lite for android while using libgdx framework to have a fancy synchronized database between laptop and phone. Unfortunatly, I'm getting one error.

Couchbase lite version is 1.0.4-28.

In my main build.gradle, I have:
dependencies {
   
...
    compile "com.couchbase.lite:couchbase-lite-android:$couchbaseVersion"
}

For the android project:
android {
   
buildToolsVersion "22.0.1"
    compileSdkVersion 22
    sourceSets {
       
main {
            manifest
.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
           
aidl.srcDirs = ['src']
           
renderscript.srcDirs = ['src']
            res
.srcDirs = ['res']
            assets
.srcDirs = ['assets']
       
}

       
instrumentTest.setRoot('tests')
   
}

   
packagingOptions {
       
exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

And finally my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.btsit.game.android"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/GdxTheme" >
        <activity
            android:name="com.btsit.game.android.AndroidLauncher"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

When trying to create manager, I have an io exception:
Caused by: java.io.IOException: Unable to create directory for: /data/data/com.couchbase.lite.test/files/cblite
       at com.couchbase.lite.Manager.<init>(Manager.java:129)

Context is retrieved in AndroidApplication with:
new AndroidContext(this)

Manager is created using couchbase-lite-java-core in an another project.

This error may only occurs on simulator, as my testing phone is quite old I can't test the app on it :(.

Does someone have any idea?

Hideki Itakura

unread,
May 20, 2015, 1:35:58 PM5/20/15
to mobile-c...@googlegroups.com
Hi Erwana,

> Caused by: java.io.IOException: Unable to create directory for: /data/data/com.couchbase.lite.test/files/cblite
       at com.couchbase.lite.Manager.<init>(Manager.java:129)

`com.couchbase.lite.test` indicates couchbase test package. And `/files/cblite` should be `/files/<database name>.cblite`. Currently I am not sure what causes your problem.


> Couchbase lite version is 1.0.4-28.

Current official release version is `1.0.4`. And if you are interested in v1.1 developer preview version, please use `1.1.0-11`.

Thanks!
Hideki

James Nocentini

unread,
Aug 26, 2015, 12:35:33 AM8/26/15
to Couchbase Mobile
I'm seeing the same error when using J2ObjC in the hope to write the models of an application with couchbase-lite-java and reuse them on iOS and Android with J2ObjC.

I think the problem may come from the fact that I'm creating the couchbase lite manager in a pure java app but running on Android.

@Erwan, you said the manager in your case was created using couchbase-lite-java-core. So it looks like the same probelm. Did you manager to solve the issue?

@Hideki, I get the same error. `08-26 00:28:32.565    3599-3599/com.couchbase.j2objcsampleandroidapp W/System.err﹕java.io.IOException: Unable to create directory for: /data/data/com.couchbase.lite.test/files/cblite`.
I'm not sure why the test package `com.couchbase.lite.test` appears on that line in LogCat.

James

Hideki Itakura

unread,
Aug 26, 2015, 1:33:13 AM8/26/15
to Couchbase Mobile
Hi @james,

couchbase-lite-java does not run on Android.

Reasons:
1. couchbase-lite-java contains Context class that may not work on Android. 
2. couchbase-lite-java depends on couchbase-lite-java-native which contains native SQLite and Collators which might work on Android even if they are compiled for Android architecture.

From the log message, I think reason 1 causes problem.

Thanks,
Hideki

James Nocentini

unread,
Aug 26, 2015, 1:47:06 AM8/26/15
to Couchbase Mobile
Yes indeed I think reason 1 is related to the JavaContext class on this line. I will try to add couchbase-lite-java as a submodule and change that line to something like `data/data/<android_application_id>/files` to see if that changes anything.

James

James Nocentini

unread,
Aug 26, 2015, 11:39:11 AM8/26/15
to Couchbase Mobile
I tried again by using a Context that writes to `data/data/<android_application_id>/files` and it fixes the reason you outlined above.

But now another error occured which is probably related to reason 2:

08-26 11:35:24.581    1826-1826/com.couchbase.j2objcsampleandroidapp E/com.couchbase.lite﹕ Native: Library not found: /native/linux/i686/libCouchbaseLiteJavaNative.so
08-26 11:35:24.582    1826-1826/com.couchbase.j2objcsampleandroidapp E/com.couchbase.lite﹕ Native: Error loading library: CouchbaseLiteJavaNative
...
08-26 11:35:24.582    1826-1826/com.couchbase.j2objcsampleandroidapp E/art﹕ No implementation found for long com.couchbase.lite.storage.JavaSQLiteStorageEngine._open(java.lang.String) (tried Java_com_couchbase_lite_storage_JavaSQLiteStorageEngine__1open and Java_com_couchbase_lite_storage_JavaSQLiteStorageEngine__1open__Ljava_lang_String_2)

So it turns out that Couchbase Lite and J2ObjC aren't compatible but it was worth the time to investigate if it'd be possible.

James

On Wednesday, 26 August 2015 09:33:13 UTC+4, Hideki Itakura wrote:

Hideki Itakura

unread,
Aug 26, 2015, 1:29:10 PM8/26/15
to mobile-c...@googlegroups.com
Hi @james,

Did you compile couchbase-lite-java-native? And, does libCouchbaseLiteJavaNative.so exist in library path?

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/3jbqii_enHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/c364562a-0bbf-4624-b678-92fdaee1cd70%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Thanks,
Hideki Itakura

Reply all
Reply to author
Forward
0 new messages