【发布时间】:2016-05-07 09:11:30
【问题描述】:
我正在尝试使用以下代码将图像保存在 firebase 上。
Bitmap bm = BitmapFactory.decodeFile(imgDecodableString);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG,100,baos);
byte[] byteArray = baos.toByteArray();
String encodedImage = Base64.encodeToString(byteArray,Base64.DEFAULT);
但我遇到了一个错误:
cannot resolve method 'encodeToString(byte[],?)'
cannot resolve symbol 'DEFAULT'
如何解决此错误。
【问题讨论】:
-
您导入了错误的
Base64类。应该是android.util.Base64,而不是org.apache.commons.codec.binary.Base64。 -
你的问题解决了吗??
-
现在我开始工作了。我导入了错误的类。
-
什么是正确的答案然后面临同样的问题
-
Yogesh Borhade,现在不需要使用 base64 字符串,现在 firebase 推出了非常简单有效的解决方案来保存图像和多媒体文件名称 Firebase Storage 请转到 firebase.google.com 并查看文档部分.希望您的问题能得到解决。
标签: android firebase firebase-realtime-database