Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 250
hcancan Avatar asked Jun 14 '17 08:06

hcancan


1 Answers

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

like image 186
andrikeev Avatar answered Sep 21 '22 23:09

andrikeev