Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
larsfredrik
2,943 PointsFailed to send recorded video! Please help!
I've come to the "Sending the message" video in the self-destructing app project, but when I try to send a captured video, the app closes and says "Unfortunately, Lecture (The name of my app) has stopped". I searched up in the logcat, but I can't find the error. I've replaced parts of the code with the ones in the project files download, but I still get the error. This is the logcat error I'm getting:
02-10 21:31:31.201: I/MainActivity(1857): Media URI: content://media/external/images/media/1997
02-10 21:31:33.463: D/dalvikvm(1857): GC_FOR_ALLOC freed 1435K, 39% free 6938K/11203K, paused 28ms, total 28ms
02-10 21:31:33.483: D/dalvikvm(1857): GC_FOR_ALLOC freed 30K, 30% free 7931K/11203K, paused 22ms, total 22ms
02-10 21:31:33.513: D/dalvikvm(1857): GC_FOR_ALLOC freed 38K, 19% free 9151K/11203K, paused 21ms, total 21ms
02-10 21:31:33.523: I/dalvikvm-heap(1857): Grow heap (frag case) to 16.904MB for 644296-byte allocation
02-10 21:31:33.563: D/dalvikvm(1857): GC_FOR_ALLOC freed 2599K, 40% free 7183K/11847K, paused 25ms, total 25ms
02-10 21:31:33.663: I/dalvikvm-heap(1857): Grow heap (frag case) to 28.430MB for 14745616-byte allocation
02-10 21:31:33.693: D/dalvikvm(1857): GC_CONCURRENT freed <1K, 18% free 21583K/26311K, paused 2ms+3ms, total 30ms
02-10 21:31:33.833: D/dalvikvm(1857): GC_FOR_ALLOC freed <1K, 18% free 21584K/26311K, paused 24ms, total 24ms
02-10 21:31:33.953: I/dalvikvm-heap(1857): Grow heap (frag case) to 39.543MB for 11653136-byte allocation
02-10 21:31:33.983: D/dalvikvm(1857): GC_CONCURRENT freed <1K, 13% free 32964K/37703K, paused 9ms+4ms, total 33ms
02-10 21:31:41.471: D/dalvikvm(1857): GC_FOR_ALLOC freed 16380K, 49% free 20611K/39751K, paused 21ms, total 21ms
02-10 21:31:45.425: D/dalvikvm(1857): GC_FOR_ALLOC freed 2047K, 44% free 22658K/39751K, paused 20ms, total 20ms
02-10 21:32:01.380: I/MainActivity(1857): Media URI: content://media/external/video/media/1979
02-10 21:32:38.987: D/dalvikvm(1857): GC_FOR_ALLOC freed 16977K, 73% free 11089K/39751K, paused 28ms, total 28ms
02-10 21:32:38.997: D/skia(1857): --- SkImageDecoder::Factory returned null
02-10 21:32:38.997: D/skia(1857): --- SkImageDecoder::Factory returned null
02-10 21:32:38.997: D/AndroidRuntime(1857): Shutting down VM
02-10 21:32:38.997: W/dalvikvm(1857): threadid=1: thread exiting with uncaught exception (group=0x41683318)
02-10 21:32:39.027: E/AndroidRuntime(1857): FATAL EXCEPTION: main
02-10 21:32:39.027: E/AndroidRuntime(1857): java.lang.NullPointerException
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:461)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.larsfso.lecture.ImageResizer.resizeImage(ImageResizer.java:27)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.larsfso.lecture.ImageResizer.resizeImageMaintainAspectRatio(ImageResizer.java:55)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.larsfso.lecture.FileHelper.reduceImageForUpload(FileHelper.java:67)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.larsfso.lecture.RecipientsActivity.createMessage(RecipientsActivity.java:174)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.larsfso.lecture.RecipientsActivity.onOptionsItemSelected(RecipientsActivity.java:129)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.app.Activity.onMenuItemSelected(Activity.java:2534)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:965)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:514)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:99)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.view.View.performClick(View.java:4103)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.view.View$PerformClick.run(View.java:17117)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.os.Handler.handleCallback(Handler.java:615)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.os.Handler.dispatchMessage(Handler.java:92)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.os.Looper.loop(Looper.java:137)
02-10 21:32:39.027: E/AndroidRuntime(1857): at android.app.ActivityThread.main(ActivityThread.java:4744)
02-10 21:32:39.027: E/AndroidRuntime(1857): at java.lang.reflect.Method.invokeNative(Native Method)
02-10 21:32:39.027: E/AndroidRuntime(1857): at java.lang.reflect.Method.invoke(Method.java:511)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-10 21:32:39.027: E/AndroidRuntime(1857): at dalvik.system.NativeStart.main(Native Method)
02-10 21:33:00.698: I/Process(1857): Sending signal. PID: 1857 SIG: 9
I also have a delay with the "Message Sent" when pressing the "send" button, but I would assume this occurs after it's successfully uploaded to parse. There's also a delay when pressing "send" after selecting recipients to a "galleryphoto". The delay is about 15 seconds long. But I don't care about the delay that much.
Thanks in advance! :D
Tagging Ben Jakuben on this one... ^_^
2 Answers
Ben Jakuben
Treehouse TeacherBased on those error messages, it looks like your code is attempting to handle the video as an image (it shouldn't be using the ImageResizer class for a video. Can you debug or figure out what the mFileType value is in your send() method? Perhaps that is getting the wrong value somehow.
If you continue to have trouble, can you paste in your whole RecipientsActivity code?
Ben Jakuben
Treehouse TeacherThis line in your log output:
02-10 21:32:39.027: E/AndroidRuntime(1857): at com.larsfso.lecture.FileHelper.reduceImageForUpload(FileHelper.java:67)
Means that your code is attempting to call reduceImageForUpload(), which only happens in this block:
if (mFileType.equals(ParseConstants.TYPE_IMAGE)) {
fileBytes = FileHelper.reduceImageForUpload(fileBytes);
}
The only way you get in there is if mFileType is TYPE_IMAGE, so it does seem like that's the problem somewhere. mFileType comes from the Intent extras, so you'll need to go back to MainActivity to see how it's being set in the onActivityResult() method. It should look like this:
String fileType;
if (requestCode == PICK_PHOTO_REQUEST || requestCode == TAKE_PHOTO_REQUEST) {
fileType = ParseConstants.TYPE_IMAGE;
}
else {
fileType = ParseConstants.TYPE_VIDEO;
}
recipientsIntent.putExtra(ParseConstants.KEY_FILE_TYPE, fileType);
larsfredrik
2,943 PointsThank you so much, @BenJakuben! You're the man! I sorted it out with your help. I had this line of code:
if (requestCode == PICK_PHOTO_REQUEST || requestCode == PICK_VIDEO_REQUEST) {
Thanks for your help! You're awesome! ^_^ <3
Ben Jakuben
Treehouse TeacherHooray! Onward and upward! :)
larsfredrik
2,943 Pointslarsfredrik
2,943 PointsI will see if I can fix the problem now. But here's the whole RecipientsActivity:
Ben Jakuben