I have a piece of code to create a new String as follows:
private final static Charset UNICODE_CHARSET = Charset.forName("UTF-8"); public String makeNewUnicodeString(byte[] octects) { return new String(octects, UNICODE_CHARSET); }
It works fine when testing on my computer. But when I run it on the Android emulator, it produces:
java.lang.NoSuchMethodError: java.lang.String.<init>
But it works:
public String makeUnicodeString(byte[] octets) { try { return new String(octets, "UTF-8") } catch (UnsupportedEncodingException uee) {
I am using Android 2.2 API 8, ed. 2.
source share