János János - 1 year ago 243
Android Question

java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets

In simulator I can run my app, but on device with Jelly Bean OS I get a crash. Any idea why?

07-04 12:51:57.576 18243-18279/com.j4nos.moviebuffs6 E/AndroidRuntime: FATAL EXCEPTION: Thread-7940
java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at com.j4nos.moviebuffs6.Utility$1.run(Utility.java:52)
at java.lang.Thread.run(Thread.java:838)

This is the line I need character encoding:

byte[] out = str.getBytes(StandardCharsets.UTF_8);

Answer Source

StandardCharsets was added in API Level 19. It is not available for any of the Jelly Bean versions of Android.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download