我正在使用Facebook的API来创建一个带有我的Android应用程序图片的新专辑,但我继续得到这些令人讨厌的错误,这是毫无意义的。我做了一些研究但没有提出任何问题。请帮忙!
String albumName = ((TextView)findViewById(R.id.album_name)).getText().toString();
Bundle params = new Bundle();
params.putByteArray("pictures", toByteArray(mediaPath[0]));
params.putString("name", albumName);
request.request("https://graph.facebook.com/me/albums",params,"POST", new UploadListener(), new Object());
看看我的日志猫
01-26 15:51:50.501:W / Bundle(616):键格式预期byte []但值是java.lang.String。返回了默认值。 01-26 16:07:48.871:D / Facebook-Util(670):POST URL:https://graph.facebook.com/https://graph.facebook.com/me/albums 01-26 16:07:48.891:W / Bundle(670):键格式预期byte []但值是java.lang.String。返回了默认值。 01-26 16:07:48.891:W / Bundle(670):尝试转换生成的内部异常: 01-26 16:07:48.891:W / Bundle(670):java.lang.ClassCastException:java.lang.String 01-26 16:07:48.891:W / Bundle(670):在android.os.Bundle.getByteArray(Bundle.java:1305) 01-26 16:07:48.891:W / Bundle(670):at com.facebook.android.Util.openUrl(Util.java:155) 01-26 16:07:48.891:W / Bundle(670):at com.facebook.android.Facebook.request(Facebook.java:717) 01-26 16:07:48.891:W / Bundle(670):at com.facebook.android.AsyncFacebookRunner $ 2.run(AsyncFacebookRunner.java:253) 01-26 16:07:49.390:D / dalvikvm(670):GC_CONCURRENT释放2526K,57%自由4489K / 10311K,外部5789K / 6493K,暂停5ms + 4ms 01-26 16:07:49.560:W / Bundle(670):键方法期望byte []但值是java.lang.String。返回了默认值。 01-26 16:07:49.560:W / Bundle(670):尝试转换生成的内部异常: 01-26 16:07:49.560:W / Bundle(670):java.lang.ClassCastException:java.lang.String 01-26 16:07:49.560:W / Bundle(670):在android.os.Bundle.getByteArray(Bundle.java:1305) 01-26 16:07:49.560:W / Bundle(670):at com.facebook.android.Util.encodePostBody(Util.java:63) 01-26 16:07:49.560:W / Bundle(670):at com.facebook.android.Util.openUrl(Util.java:182) 01-26 16:07:49.560:W / Bundle(670):at com.facebook.android.Facebook.request(Facebook.java:717) 01-26 16:07:49.560:W / Bundle(670):at com.facebook.android.AsyncFacebookRunner $ 2.run(AsyncFacebookRunner.java:253) 01-26 16:07:49.570:W / Bundle(670):键格式预期byte []但值是java.lang.String。返回了默认值。 01-26 16:07:49.570:W / Bundle(670):尝试转换生成的内部异常: 01-26 16:07:49.570:W / Bundle(670):java.lang.ClassCastException:java.lang.String 01-26 16:07:49.570:W / Bundle(670):在android.os.Bundle.getByteArray(Bundle.java:1305) 01-26 16:07:49.570:W / Bundle(670):at com.facebook.android.Util.encodePostBody(Util.java:63) 01-26 16:07:49.570:W / Bundle(670):at com.facebook.android.Util.openUrl(Util.java:182) 01-26 16:07:49.570:W / Bundle(670):at com.facebook.android.Facebook.request(Facebook.java:717) 01-26 16:07:49.570:W / Bundle(670):at com.facebook.android.AsyncFacebookRunner $ 2.run(AsyncFacebookRunner.java:253) 01-26 16:07:49.610:D / dalvikvm(670):GC_FOR_MALLOC释放258K,57%免费4445K / 10311K,外部5789K / 6493K,暂停38ms 01-26 16:07:49.620:I / dalvikvm-heap(670):将堆(frag case)增长到15.307MB,用于2903026字节分配 01-26 16:07:49.670:D / dalvikvm(670):GC_FOR_MALLOC释放<1K,45%自由7280K / 13191K,外部5789K / 6493K,暂停32ms 01-26 16:07:49.781:D / dalvikvm(670):GC_CONCURRENT释放4K,45%自由7280K / 13191K,外部5789K / 6493K,暂停4ms + 5ms 01-26 16:07:54.990:W / dalvikvm(670):threadid = 16:线程退出未捕获异常(组= 0x40015560) 01-26 16:07:54.990:E / AndroidRuntime(670):致命异常:Thread-19
答案 0 :(得分:1)
尝试更换:
params.putByteArray("pictures", toByteArray(mediaPath[0]));
使用:
params.putString("pictures", mediaPath[0]);
显然对字节[]不满意,所以这就是我开始的地方。 (假设mediaPath []是一个字符串数组,顾名思义。
如果这不起作用,请先尝试创建相册,然后添加图片,检查解决方案here for working album creation: