import org.apache.commons.codec.binary.Base64;
import java.util.Base64;
运行代码时出现错误。
private void upload() {
Bitmap bm = BitmapFactory.decodeFile(mCurrentPhotoPath);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 50, bao);
byte[] ba = bao.toByteArray();
ba1 = Base64.encodeBytes(ba);
// Upload image to server
new uploadToServer().execute();
}
我得到的错误是:
Error:(81, 21) error: cannot find symbol method encodeBytes(byte[])
Error:(43, 25) error: cannot find symbol class Base64
答案 0 :(得分:3)
您正在导入Java库。使用Android库代替Base64。
import android.util.Base64;