2

Actually, I am developing an Android Application with encryption. When I use the Base64 for encoding and decoding, I receive an error of

Java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String() 

at run-time.

I know there are some posts on Stackflow which has been discussed the main cause of the problem ==> there are different versions of commons-codec.

Could anybody describe how to solve this problem in details? (So far, I know two solutions are workable).

1) Import the org.apache.commons.codec.binary.Base64 as client named package.;
2) Update the default lib of commons-codec)

Currently, I am using adt-bundle-windows-x86-20131030 for developing my application. Here is some of the coding for reference.

import org.apache.commons.codec.binary.Base64;

public static String receiveSetup(String messageFromActivity)
        throws Exception {
    SecretKey tempKey2 = DES.loadKey();
    byte[] test2 = Base64.decodeBase64(messageFromActivity);
    byte[] printString = DES.decrypt(test2, tempKey2);
    String str = new String(printString, "UTF-8");
    return str;
}
1
  • @super-qua I am new to this platform. Thanks for editing the question for me. Many thanks! Commented Mar 13, 2014 at 11:59

2 Answers 2

1

Base64#encodeBase64String method was added in version 1.4 of Commons Codec library.

The thing is that the Android framework includes this class, and the runtime will use its version (and not the class that you packaged inside your app). Since framework shipped with version 1.3 of Commons Codec, the requested method is not present.

Check out my answer here that includes steps to resolve this issue.

Sign up to request clarification or add additional context in comments.

Comments

0

have u aware about sun.misc.BASE64Decoder jar file just include this jar file in your project dude name is sun.misc.BASE64Decoder

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.