3
EncodingUtils.getBytes(payload, "BASE64");

this is the line which we were using with apache library included in gradle to get bytes of payload string with char set as BASE64

after removing this

useLibrary  'org.apache.http.legacy' 

Encoding util class is not getting resolved so what is the best way to do this same function in Android ?

Input

device_type=1&firstname=hhj&=

This is the way the input would be a long string which has other parameters too output would be in bytes since i have to post this result in url like this

mWebView.postUrl(url, myRes);
Pallav Grover
  • 55
  • 2
  • 8
  • Not quite without apache, but without that one, though with another lib: http://stackoverflow.com/questions/13109588/base64-encoding-in-java – Gavriel Feb 24 '16 at 06:37
  • Also according to http://stackoverflow.com/questions/23318109/is-it-possible-to-use-java-8-for-android-development if you need only for android 5.0+ then you can use the 1 line Java 8 solution from the previous link – Gavriel Feb 24 '16 at 06:40
  • Isn't there a way without any library like android inbuilt class or something? – Pallav Grover Feb 24 '16 at 06:41
  • Since API level 8 there is http://developer.android.com/reference/android/util/Base64.html – Sami Kuhmonen Feb 24 '16 at 06:43
  • So we are removing the apache library for all versions not only for marshmallow – Pallav Grover Feb 24 '16 at 06:43

1 Answers1

1

Android has a built-in Base64 class which can be used, starting from API level 8.

Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74