RusticiSoftware / TinCanJava

Tin Can Java Library
http://rusticisoftware.github.io/TinCanJava/
Apache License 2.0
44 stars 46 forks source link

java.lang.NoSuchMethodError encodeBase64String #57

Closed omis76 closed 2 years ago

omis76 commented 7 years ago

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.

garemoko commented 7 years ago

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

omis76 commented 7 years ago

xAPI 1.0.x or TinCanAPI 1.0.x

garemoko commented 7 years ago

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

omis76 commented 7 years ago

capture

i am getting this error for tincan 1.1.0

omis76 commented 7 years ago

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

garemoko commented 7 years ago

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

brianjmiller commented 7 years ago

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.

nileshappic commented 6 years ago

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.