0

In API 7 when try

val string = "string"
val bytes = string.toByteArray(Charset.forName("UTF-8"))

I get this exception:

java.lang.NoSuchMethodError: java.lang.String.getBytes

Is any way to get bytes from string without standard method? Looks like, conversion string to byte array starts with Api 8.

1 Answer 1

1

There are versions of getBytes() on String that work back to API Level 1, such as this one.

Sign up to request clarification or add additional context in comments.

1 Comment

Possible, it's a feature of device, which i use for tests(eBook), but all methods of getBytes() ends with this exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.