Couchbase mobile 2.0 Emoji Support


I have a working android app with couchbase mobile version 1.5. Now I am trying to upgrade to version 2.0, but i get following error when I try to read strings which contain Emojis:

07-01 23:31:53.000 21164-21188/ A/art: art/runtime/] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0xf0
    art/runtime/]     string: '🌎' 
07-01 23:31:53.001 21164-21188/ A/art: art/runtime/]     in call to NewStringUTF
    art/runtime/]     from java.lang.String com.couchbase.litecore.fleece.FLValue.asString(long)
    art/runtime/] "ForkJoinPool.commonPool-worker-0" daemon prio=5 tid=14 Runnable
    art/runtime/]   | group="main" sCount=0 dsCount=0 obj=0x12c0e920 self=0xada8cc00
    art/runtime/]   | sysTid=21188 nice=0 cgrp=apps sched=0/0 handle=0xad4a1800
    art/runtime/]   | state=R schedstat=( 0 0 0 ) utm=14 stm=1 core=1 HZ=100
    art/runtime/]   | stack=0xa44fe000-0xa4500000 stackSize=1036KB
    art/runtime/]   | held mutexes= "mutator lock"(shared held)
    art/runtime/]   native: #00 pc 00004640  /system/lib/ (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
    art/runtime/]   native: #01 pc 00002e8d  /system/lib/ (Backtrace::Unwind(unsigned int, ucontext*)+8)
    art/runtime/]   native: #02 pc 0023f455  /system/lib/ (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
    art/runtime/]   native: #03 pc 00224617  /system/lib/ (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+146)
    art/runtime/]   native: #04 pc 000af913  /system/lib/ (art::JniAbort(char const*, char const*)+582)
    art/runtime/]   native: #05 pc 000b004d  /system/lib/ (art::JniAbortF(char const*, char const*, ...)+60)
    art/runtime/]   native: #06 pc 000b24a7  /system/lib/ (art::ScopedCheck::Check(bool, char const*, ...) (.constprop.128)+882)
    art/runtime/]   native: #07 pc 000baf11  /system/lib/ (art::CheckJNI::NewStringUTF(_JNIEnv*, char const*)+36)
    art/runtime/]   native: #08 pc 000d4def  /data/app/ (litecore::jni::toJString(_JNIEnv*, C4Slice)+62)
    art/runtime/]   native: #09 pc 000d63d1  /data/app/ (Java_com_couchbase_litecore_fleece_FLValue_asString+32)
    art/runtime/]   native: #10 pc 000a2311  /system/lib/ (art_quick_generic_jni_trampoline+32)
    art/runtime/]   native: #11 pc 0014e8f4  /dev/ashmem/dalvik-alloc space (deleted) (???)
    art/runtime/]   at com.couchbase.litecore.fleece.FLValue.asString(Native method)
    art/runtime/]   at com.couchbase.litecore.fleece.FLValue.asString(
    art/runtime/]   at com.couchbase.litecore.fleece.FLValue.toObject(
    art/runtime/]   at com.couchbase.lite.MValueDelegate.toNative(
    art/runtime/]   at com.couchbase.litecore.fleece.MValue.toNative(
    art/runtime/]   at com.couchbase.litecore.fleece.MValue.asNative(
    art/runtime/]   at com.couchbase.lite.Dictionary.getString(
    art/runtime/]   - locked <0x3dbc9de3> (a java.lang.Object)
    art/runtime/]   at
    art/runtime/]   at
    art/runtime/]   at$loadVokPckList$data$1.doResume(AppData.kt:39)
    art/runtime/]   at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
    art/runtime/]   at kotlinx.coroutines.experimental.DispatchedTask$
    art/runtime/]   at
    art/runtime/]   at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(
    art/runtime/]   at java.util.concurrent.ForkJoinTask.doExec(
    art/runtime/]   at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(
    art/runtime/]   at java.util.concurrent.ForkJoinPool.scan(
    art/runtime/]   at java.util.concurrent.ForkJoinPool.runWorker(
    art/runtime/]   at

this is my code I used(It is written in Kotlin):

    val doc = database!!.getDocument("SysVok::Structure")
    val pcks = doc.getArray("Pcks")
    val pck = pcks.getDictionary(0)
    val emoji = pck.getString("Emoji") // <-- Error

Is this some kind of Bug? If so, are there workarounds?


Looks like an issue with how JNI deals with strings. See

I’m not sure if this can be worked around in a platform agnostic way. In Java it looks like you want to use UTF 16 “surrogate code pairs”. See

Please file an issue on GitHub so we can track this. Thanks.


Thanks for your supply.
I have created a new issue on github:

But I dont know how to solve this without changing couchbase source code.


 val emoji = pck.getValue("Emoji")

still causes the same issue.