最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

unresolved reference hexformat: Android Kotlin - Stack Overflow

programmeradmin2浏览0评论

Android 12

I am trying to secure username and password before sending it over the internet to the server. However, I need to convert my strings into HEX and I keep getting HexFormat: unresolved reference error. There seems to be no class or library associated with that. How do I solve this error? Is there a library I need to download and install?

Unresolved Reference: HexFormat

private fun ByteArray.toHexString(): String = HexFormat.of().formatHex(this)
                                                  /|\
                                                   |
                                                   |
                                                   |

edit:

Android 12

I am trying to secure username and password before sending it over the internet to the server. However, I need to convert my strings into HEX and I keep getting HexFormat: unresolved reference error. There seems to be no class or library associated with that. How do I solve this error? Is there a library I need to download and install?

Unresolved Reference: HexFormat

private fun ByteArray.toHexString(): String = HexFormat.of().formatHex(this)
                                                  /|\
                                                   |
                                                   |
                                                   |

edit:

Share Improve this question edited Jan 17 at 17:35 ThN asked Jan 17 at 17:12 ThNThN 3,2745 gold badges64 silver badges120 bronze badges 1
  • 1 did you import import java.util.HexFormat? – tyczj Commented Jan 17 at 17:15
Add a comment  | 

2 Answers 2

Reset to default 1

HexFormat was add in API 34, Android 12 is API 31 so you wont be able to use it in anything below Android 14

use ByteArray.toHexString(format: HexFormat = HexFormat.Default).
package kotlin.text @SinceKotlin("1.9")

发布评论

评论列表(0)

  1. 暂无评论