1

I am trying to use a java library inside my android project with android studio but I get the next error log:

UncaughtException: java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; 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)

This is the external library I want to use:

implementation files('libs/CoDiLibrary.jar')

and inside the onCreate method of my MainActivity I do this:

String keySource = CoDi.keySource("123456","3434j34h43j","5551234567");

these are the dependencies in my project:

    dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation files('libs/CoDiLibrary.jar')
}

What do I have to change to make it work on any api level device?

Luis Aguilar
  • 645
  • 9
  • 26
  • I believe the issue comes from the last library added to gradle >> implementation files('libs/commons-codec-1.10.jar')}. Can you remove it and retry? Maybe it is in conflict with the same default common codecs library brought by android. – Hichem BOUSSETTA Apr 09 '19 at 23:42
  • @HichemBOUSSETTA Still not working. What I did is to change compileSdkVersion and targetSdkVersion to api level 28 and it worked for an api level 28 device but, after testing it with a device with api level 26 the same error ocurred. – Luis Aguilar Apr 09 '19 at 23:51
  • Where you put `libs` folder? please remove this `implementation files('libs/CoDiLibrary.jar')` and make sure that the `libs` should be like this `app/libs` not `app/src/libs` – NamNH Apr 10 '19 at 04:44
  • @NamNH yes, the library is inside app/libs – Luis Aguilar Apr 10 '19 at 04:53
  • @LuisAguilar I don't know which is your `CoDiLibrary.jar` contains, but at least you can understand the same scenario in [this post](https://stackoverflow.com/questions/9126567/method-not-found-using-digestutils-in-android) – NamNH Apr 10 '19 at 06:38

0 Answers0