login about faq

We are using the latest Android lib on our app. Works well. We recently received an email (apparently) that from what we can tell, is plain text... nothing special. Our APP is hard crashing all of a sudden.

Doing some internal debugging using Android Studio, my code cycles through a batch of messages, then the 12th message in, it "appears" to be hard crashing, internally, when retrieving the messages body from the server. The code works ok with date, subject, to, from, cc, bcc... no issues.

The code we have to retrieve the body is:

             if (email.HasHtmlBody())

As mentioned, this same routine works on multiple previous messages.. without an issue.

When I look at the error log in Android Studio, it says...

JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0xf0 ' in call to NewStringUTF from java.lang.String com.chilkatsoft.chilkatJNI.CkEmail_getPlainTextBody(long, com.chilkatsoft.CkEmail) "main" prio=5 tid=1 Runnable | group="main" sCount=0 dsCount=0 obj=0x736c3000 self=0xb4827800 | sysTid=25368 nice=0 cgrp=apps sched=0/0 handle=0xb6ff0bec | state=R schedstat=( 0 0 0 ) utm=33 stm=11 core=0 HZ=100 | stack=0xbe4ad000-0xbe4af000 stackSize=8MB | held mutexes= "mutator lock"(shared held) native: #00 pc 00004f60 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext)+23) native: #01 pc 00003665 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext)+8) native: #02 pc 00256a61 /system/lib/libart.so (art::DumpNativeStack(std::1::basic_ostream<char, std::__1::char_traits<char=""> >&, int, char const, art::mirror::ArtMethod)+84) native: #03 pc 00239617 /system/lib/libart.so (art::Thread::Dump(std::1::basic_ostream<char, std::__1::char_traits<char=""> >&) const+158) native: #04 pc 000b198b /system/lib/libart.so (art::JniAbort(char const, char const)+610) native: #05 pc 000b20c5 /system/lib/libart.so (art::JniAbortF(char const, char const, ...)+68) 0 native: #06 pc 000b467f /system/lib/libart.so (art::ScopedCheck::Check(bool, char const, ...) (.constprop.129)+922) 0 native: #07 pc 000be1ad /system/lib/libart.so (art::CheckJNI::NewStringUTF(_JNIEnv, char const)+44) 0 native: #08 pc 00100d43 /data/app/com.retreve.retreve-1/lib/arm/libchilkatemail.so (_JNIEnv::NewStringUTF(char const)+8) 0 native: #09 pc 00110e19 /data/app/com.retreve.retreve-1/lib/arm/libchilkatemail.so (Java_com_chilkatsoft_chilkatJNI_CkEmail_1getPlainTextBody+20) native: #10 pc 00104ce5 /data/dalvik-cache/arm/data@app@com.retreve.retreve-1@base.apk@classes.dex (Java_com_chilkatsoft_chilkatJNI_CkEmail_1getPlainTextBody__JLcom_chilkatsoft_CkEmail_2+120) at com.chilkatsoft.chilkatJNI.CkEmail_getPlainTextBody(Native method)

Hopefully this makes sense to you guys because it doesn't appear to be anything we are doing wrong, I don't think.

asked Feb 15 '16 at 21:10

pbrama's gravatar image


This new build should fix it:

This was the cause of the problem:

Chilkat itself is not crashing. What's happening is that the string returned by getPlainTextBody likely contains an Emoji character. Emoji characters are represented in utf-8 in 4 bytes. For example, see the "grinning face" Emoji: http://www.iemoji.com/view/emoji/885/people/grinning-face

In utf-8, the Emoji grinning face is represented by these 4 bytes: 0xF0 0x9F 0x98 0x80

This is what's happening: Chilkat is returning the utf-8 for the Emoji char via the JNI function NewStringUTF (see https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#NewStringUTF )

The NewStringUTF function does not like the 4-byte utf-8 of the Emoji char and throws an exception. Apparently, JNI uses a "modified-UTF8" such that it does not handle chars encoded in 4 bytes. See http://banachowski.com/deprogramming/2012/02/working-around-jni-utf-8-strings/


answered Feb 16 '16 at 07:48

chilkat's gravatar image

chilkat ♦♦

edited Jul 20 '16 at 20:24

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Feb 15 '16 at 21:10

Seen: 2,088 times

Last updated: Jul 20 '16 at 20:24

powered by OSQA