Android studio: NoClassDefFoundError with java.util.Base64

Just replace

import java.util.Base64;

with

import android.util.Base64;

And then modify your code to something like this (just an example):

String encoded = Base64.encode(someString.getBytes(), Base64.DEFAULT)); // for encoding
String decoded = Base64.decode(encoded, Base64.DEFAULT)); // for decoding

replace java.util.Base64 with android.util.Base64. android doesn't use openjdk or oracle jre so the standard packages may not be there.