RusticiSoftware/TinCanJava

java.lang.NoSuchMethodError encodeBase64String

Closed this issue · 8 comments

I am getting below exception while integrating TinCanApi 0.9 in my android studio project.
Below is the exception

java.lang.NoSuchMethodError: No static method encodeBase64String([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)

Please suggest.

Hi @omis76

Don't use 0.9, that's a really bad idea. xAPI 1.0.x has been out for 3.5 years now. You should use that.

Andrew

xAPI 1.0.x or TinCanAPI 1.0.x

Either is fine. It's two names for the same thing.

capture

i am getting this error for tincan 1.1.0

after fixing this i am getting same error as i asked before in tincan 1.1.0 also

I'll have to leave this to the Java experts now, but at least you are on the right version.

Also, are you the Onkar Gupta who just emailed me about an example android project? I don't have any example android prototypes I'm afraid. You could ask here: https://groups.google.com/a/adlnet.gov/forum/#!forum/xapi-design

Some Googling of that error suggests that the Apache commons-codec dependency that we rely on for doing Base64 encoding is being automatically included by Android and is a very old version (1.2 seemingly). Our dependency list has it specified at 1.7 which is itself quite old (since 1.10 the latest is now 2+ years old). There is information available in:

http://stackoverflow.com/questions/2047706/apache-commons-codec-with-android-could-not-find-method
http://stackoverflow.com/questions/5147789/nosuchmethoderror-using-commonc-codec-in-android-application

Though most of the solutions in those appear to suggest changing the source code itself, which naturally won't work in this case. The following answer seems to provide a way to include a newer version of the library which includes that method and is generally the best answer I found:

http://stackoverflow.com/questions/12285615/how-to-resolve-a-library-conflict-apache-commons-codec/26548748#26548748

That at least suggests a path for a workaround using maven, I realize you're using Gradle and I don't personally have enough experience with it to know how to adjust what you have to match.

Alternatively you could fork, adjust the source to work using the solutions from the first couple of posts, and build the jar yourself to include. Obviously this isn't ideal going forward as you'll have to manually merge changes, etc.

I'm getting exception while integration of JWT encoding, please help somebody...

Exception

java.lang.NoSuchMethodError: No static method encodeBase64URLSafeString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)

Thanks in advance.