Home » Android » Alternative of DatatypeConverter.printHexBinary(byte[] array) and DatatypeConverter.parseHexBinary(String str) in Android

Alternative of DatatypeConverter.printHexBinary(byte[] array) and DatatypeConverter.parseHexBinary(String str) in Android

Posted by: admin May 14, 2020 Leave a comment

Questions:

what are the alternative of DatatypeConverter.printHexBinary(byte[] array) and DatatypeConverter.parseHexBinary(String str) in Android. Android don’t have classDef of java.xml.bind.DatatypeConverter

How to&Answers:

You are probably better off using the hexadecimal encoding/decoding found in the Apache commons codec library. Please make sure you are using the correct version of the library though, for more information look here

Answer:

For android (gradle) dependencies just use

implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.12-b140109.1041'
implementation group: 'xerces', name: 'xercesImpl', version: '2.12.0'