Android: gradle exclude commons-codec

TheModularMind picture TheModularMind · Aug 12, 2015 · Viewed 9.1k times · Source

In my android project I need commons-codec 1.8 and I would like to exclude the built-in commons-codec version. I also have some maven dependencies and I want them use 1.8 instead of built-in.

Here is the error message, it looks like the built in jar is in /system/framework/ext.jar

java.lang.NoSuchMethodError: No static method encodeHex([BZ)[C in class
 Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of
 'org.apache.commons.codec.binary.Hex' appears in /system/framework/ext.jar)

Answer

Toda Raba picture Toda Raba · Nov 5, 2015

add to your build.gradle file

dependencies {
    compile 'commons-codec:commons-codec:1.8'
}