java.lang.IllegalArgumentException: bad base-64
I am trying to encode and decode a String using android.util.Base64, but it gives a bad base-64 error. The code with the problem is: private byte[] base64ToByte(String str) throws IOException { Log.i("encription", str); byte[] returnbyteArray = Base64.decode(str, Base64.URL_SAFE); return returnbyteArray; } The error logcat is: 08-09 13:02:18.589: E/AndroidRuntime(29827): Process: com.example.maptest, PID: 29827 08-09 13:02:18.589: E/AndroidRuntime(29827): java.lang.IllegalArgumentException: bad base-64 08-09 13:02:18.589: E/AndroidRuntime(29827): at android.util.Base64.decode(Base64.java:161)