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:
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...
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 at 21:10
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/