Replace javax.xml.bind.DatatypeConverter with java.util.Base64 for Java 9+ compatibility #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses the issue where the library fails to run on Android and newer versions of Java (Java 9+) due to the use of
javax.xml.bind.DatatypeConverter
, which has been removed in newer Java versions and is not available in Android's runtime. The changes replacejavax.xml.bind.DatatypeConverter
withjava.util.Base64
, which is compatible with Android, Java SE, and newer versions of Java.Changes:
DatatypeConverter.parseBase64Binary()
withBase64.getDecoder().decode()
DatatypeConverter.printBase64Binary()
withBase64.getEncoder().encodeToString()
Why is this change necessary?
javax.xml.bind.DatatypeConverter
is not available in Android, causing aNoClassDefFoundError
when the library is used in Android apps.javax.xml.bind.DatatypeConverter
has been removed in Java 9 and later, making the library incompatible with newer Java versions.java.util.Base64
is a standard Java class available in both Android and Java SE (including newer versions), making the library more versatile and future-proof.Testing:
NoClassDefFoundError
.Related Issue: