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: enter image description here

1
  • 1
    did you import import java.util.HexFormat? Commented Jan 17 at 17:15

2 Answers 2

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

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

2 Comments

I was able to download and update Android Studio API level to 34 easily, but my phone's API level is still 12. I tried to update my phone's software update for the latest and the greatest and still the API level is at 12. It won't change. It looks like to me I have to completely redo my PHONE with the latest and the greatest OPERATING SYSTEM. I believe SOFTWARE UPDATE won't do. Am I correct in saying that?
@ThN: "It looks like to me I have to completely redo my PHONE with the latest and the greatest OPERATING SYSTEM" -- developers have been converting byte arrays to hex values for decades. There is a Kotlin standard function for this in Kotlin 1.9.0 and newer. And there are a variety of other options, including ones for Java that you could adapt.
0

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

Comments

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.