I am attempting to decode a Base64 encoded string in Android using the http://developer.android.com/reference/android/util/Base64.html class.
Both the encodeToString and
I had the same problem in my unit tests. I didn't realize the Base64 class I'm using is a part of the Android API, therefore
You can't use android.util.Base64 in a regular JUnit test, it must be an Instrumentation test.
However, if you really want it as a unit test, you could use the Apache Commons Base64 class instead. Include it in Gradle build:
// https://mvnrepository.com/artifact/org.apache.commons/commons-collections4
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
And then slightly different usage,
Base64.encodeBase64String(byte[] binaryData)
Base64.decodeBase64(String base64String)