关于android:如何在Kotlin中将ByteArray转换为具有指定字符集的字符串

How to convert ByteArray to String with specified charset in Kotlin

我发现在Kotlin中有一个ByteArray.toString(charset:Charset)函数,当我在android studio IDE中使用该函数时,它会收到语法错误。 但是我在Kotlin org站点中尝试了相同的代码,效果很好。 如何在Kotlin中将ByteArray转换为String?

Android Studio error Message


似乎您没有为Kotlin配置项目(类路径中没有kotlin-runtime.jar)。 尝试选择有错误的行,按Alt+Enter并在上下文菜单中选择"未配置Kotlin"->"配置"
或者手动将kotlin-runtime.jar添加到您的类路径中

enter image description here