hcancan
hcancan

Reputation: 123

How to convert ByteArray to String with specified charset in Kotlin

I found there is a ByteArray.toString(charset:Charset) function in Kotlin,when I use that function in android studio IDE,it gets a syntax error. But I have tried the same code in Kotlin org site, it works well. How can I convert a ByteArray to String in Kotlin?

Android Studio error Message

Upvotes: 9

Views: 12356

Answers (1)

andrikeev
andrikeev

Reputation: 201

It seems that you didn't configure your project for Kotlin (there is no kotlin-runtime.jar in your classpath). Try to select the line with the error, press Alt+Enter and in context menu choose "Kotlin not configured" -> "Configure" Or manually add kotlin-runtime.jar to your classpath

enter image description here

Upvotes: 4

Related Questions