Java and Android commons codec usage and nosuch method error


Commons codec, a utility class package provided by the Apache open source organization for handling common encoding methods, such as DES, SHA1, MD5, Base64, URL, Soundx, and so on. Not only encoding, but also decoding.

common classes and functions

1, Base64 encoding and decoding 2, Hex encoding and decoding 3, MD5 encryption (MD5 is an irreversible algorithm, encryption only) 4, SHA encryption 5, Metaphone and Soundex 6, URLCodec


the address
or </ p>

Java project using


Android USES

it’s a pity that did not provide gradle dependence, only from the source code or download bin file copies jars to the Android projects in use, can appear but in Android USES Java. Lang. NoSuchMethodError: No static method decodeHex (Ljava/lang/String;)
[B in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of ‘org.apache.commons.codec.binary.Hex’ appears in /system/framework/org.apache.http.legacy.boot.jar)


Android also has a copy of the package name and class name of the API we use, but the point is there is no such method in the system! This results in a package name conflict, and the system finds the same class with the same name in its SDK, and then calls the method we use below the system’s own class.
however the system does not have that method at all, it is not called at all. And then there’s no and then there’s less than /p>


obtained the source code by itself, modified the package name, and then recompiled into a jar package, and then imported into the Android project for use; Recompile and run your Own Android project, and you’ll see that the previous problems are gone;

Read More: