introduction
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
source
the address https://commons.apache.org/proper/commons-codec/download_codec.cgi
or
https://github.com/apache/commons-codec </ p>
Java project using
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
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)
why
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>
solution
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:
- java.lang.IllegalStateException: Could not execute method for android:onClick
- The usage of Java JUnit unit test and the solution of initialization error
- org.junit.platform.commons.JUnitException: TestEngine with ID ‘junit-vintage‘ failed to discover tes
- Android appears java.lang.NoClassDefFoundError A solution to the error
- Difference between isempty method and isblank method in stringutils
- Android AS Run main Method Error [How to Solve]
- Android studio displays the class and method where the cursor is located
- The method of Java jumping out of loop
- android Caused by: java.util.ConcurrentModificationException
- Error java.lang.IllegalArgumentException: Validation failed for query for method public abstract
- Android studio — java.lang.nullpointerexception(no error message)
- Java compareto() method
- Android error java.lang.IllegalStateException : System services not available to Activities before onC
- Spock + powermock simulation static method reports an error java.lang.classcastexception
- Caused by: java.lang.IllegalStateException: Ambiguou There is already ‘XXXXXXController‘ bean method
- Error: Error parsing D:\new_android\Android SDK\system-images\android-25\android-wear\armeabi-v7a\de
- [unity] Android package error java.lang.ClassNotFoundException Did not find class com.unity3d . player.MainActivity
- On the intern () method of string class in Java
- feign.codec.DecodeException
- Java uses the createnewfile() method to report an error