{"id":3359,"date":"2014-03-23T11:23:26","date_gmt":"2014-03-23T11:23:26","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/apache-commons-codec-with-android-could-not-find-method-collection-of-common-programming-errors\/"},"modified":"2014-03-23T11:23:26","modified_gmt":"2014-03-23T11:23:26","slug":"apache-commons-codec-with-android-could-not-find-method-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/apache-commons-codec-with-android-could-not-find-method-collection-of-common-programming-errors\/","title":{"rendered":"Apache Commons Codec with Android: could not find method-Collection of common programming errors"},"content":{"rendered":"<p>I had a similar problem while using android with an OAuth library I&#8217;m developing.<\/p>\n<p>I also got from android that, although I had included <code>apache.commons.codec<\/code> in the classpath, a particular method (<code>encodeBase64String<\/code>) was not found.<\/p>\n<p>Checking the javadocs, both methods claim to be <strong>1.4 and greater only<\/strong>, so my guess is that android already includes an older version of <code>commons.codec<\/code> where these methods are indeed undefined.<\/p>\n<p>My solution was to use an older method, like this:<\/p>\n<pre><code>String encodedString = new String(Base64.encodeBase64('string to encode'));\n<\/code><\/pre>\n<p>The method you want to use is different since it replaces + and \/ with url-safe values &#8211; and _. So you probably might use something like:<\/p>\n<pre><code>String encodedString = new String(Base64.encodeBase64('string to encode'));\nString safeString = encodedString.replace('+','-').replace('\/','_');\n<\/code><\/pre>\n<p>Hope that helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had a similar problem while using android with an OAuth library I&#8217;m developing. I also got from android that, although I had included apache.commons.codec in the classpath, a particular method (encodeBase64String) was not found. Checking the javadocs, both methods claim to be 1.4 and greater only, so my guess is that android already includes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3359","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3359"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3359\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}