ANDROID : java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String in android

The org.apache.commons.codec.binary.Base64 class is not part of the standard Android APIs. To fix the problem, just use the standard Base64 class that comes with Android by replacing these lines:

import org.apache.commons.codec.binary.Base64;
...
String retVal = Base64.encodeBase64String(digest);

by:

import android.util.Base64;
...
String retVal = Base64.encodeToString(digest, Base64.DEFAULT);