I am trying to upload an image to Facebook but get “Key format expected byte[]”-Collection of common programming errors
I am using Facebook’s API to create a new album with a picture from my android app but I keep on getting these annoying errors that make no sense. I have done some research but have come up with nothing. Please help!
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());
Take a look at my log cat
01-26 15:51:50.501: W/Bundle(616): Key format expected byte[] but value was a java.lang.String. The default value was returned. 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): Key format expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:48.891: W/Bundle(670): Attempt to cast generated internal exception: 01-26 16:07:48.891: W/Bundle(670): java.lang.ClassCastException: java.lang.String 01-26 16:07:48.891: W/Bundle(670): at 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 freed 2526K, 57% free 4489K/10311K, external 5789K/6493K, paused 5ms+4ms 01-26 16:07:49.560: W/Bundle(670): Key method expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:49.560: W/Bundle(670): Attempt to cast generated internal exception: 01-26 16:07:49.560: W/Bundle(670): java.lang.ClassCastException: java.lang.String 01-26 16:07:49.560: W/Bundle(670): at 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): Key format expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:49.570: W/Bundle(670): Attempt to cast generated internal exception: 01-26 16:07:49.570: W/Bundle(670): java.lang.ClassCastException: java.lang.String 01-26 16:07:49.570: W/Bundle(670): at 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 freed 258K, 57% free 4445K/10311K, external 5789K/6493K, paused 38ms 01-26 16:07:49.620: I/dalvikvm-heap(670): Grow heap (frag case) to 15.307MB for 2903026-byte allocation 01-26 16:07:49.670: D/dalvikvm(670): GC_FOR_MALLOC freed
Originally posted 2013-11-27 12:09:36.