Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9363] Android: Application forced close after taking picture from camera or selecting picture from gallery on first load.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2013-04-02T01:23:24.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sSprint 2012-19 Core, 2012 Sprint 19, Release 3.2.0
ComponentsAndroid
Labelscommunity, core
Reporternilesh kashid
AssigneeIngo Muschenetz
Created2012-05-28T04:51:09.000+0000
Updated2017-03-22T23:10:30.000+0000

Description

In android application when I am taking picture from camera and hitting "OK" or selecting image from gallery,application will forced close.This is happen when I install application on android device and using first time. after forced close when I again restart application and use this functionality,its working fine. When I tried with android 2.2 and Titanium SDK 1.8.0.1 it's working proper even on first load also and without any error and forced close.
var win = Ti.UI.currentWindow;

photo_gallery_view = Ti.UI.createView(
{
	height:'45dp',
        width:'45dp',
	backgroundColor:'#fff'
});win.add(photo_gallery_view);

photo_camera_view = Ti.UI.createView(
{
	height:'45dp'
        width:'45dp',
	backgroundColor:'#fff'
});win.add(photo_camera_view);

 the_img = Titanium.UI.createImageView({ 
 	image: 'default.png',
	height: '150dp',
	width: '50%',
	top: '10dp'
});win.add(the_img);

photo_camera_view.addEventListener('click', function(e)
{
    Titanium.Media.showCamera(
        {
            success:function(event)
            {
                the_img.image =  event.media; 
            },
            cancel : function() {
	 
	    },
	    error : function(error) 
	    {
	    	
	    },
        });
});

Comments

  1. Varun Joshi 2012-05-30

    Hi Nilesh, Could you please provide a working sample that reproduces the issue? Also, please tell is the Android device you are testing on? Thanks, Varun
  2. nilesh kashid 2012-05-30

    Download this application [http://assets.appcelerator.com.s3.amazonaws.com/app_u/code/TiBountyHunter.zip]. Build this application with titanium sdk 2.0.1 and google android api 2.2. Install this application on device with android version 2.2. I am using samsung galaxy 5 with android version 2.2. When I tried with titanium sdk 1.0.8.1 It's working fine. Not giving any error. But When i tried with titanium sdk 2.0.1 on first load it's forced close when I tried to take a photo and set as image in image view.But after first load it's working fine.
  3. nilesh kashid 2012-06-06

    My log records on android device: {quote} E/TiApplication( 9316): (main) [39,15760] Sending event: exception on thread: main msg:java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/847 }} to activity {com.votodo/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException; E/TiApplication( 9316): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/847 }} to activity {com.votodo/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException {quote}
  4. Marcel Klapschus 2012-06-08

    Can confirm this bug. It actually makes all camera operations on Android unususable. So I hope this SERIOUS bug is fixed VERY soon. Here is my code: http://developer.appcelerator.com/question/138065/camera-causing-the-app-to-crash-randomly#comment-129771 What I figured out is, that it seems to happen randomly. When I started my app for the first time and took a pic inside my app, it crashes, I started the app a second time and it worked fine. Third time: crash. Probably a memory-problem? Teted with Android 2.2 API, and SDK 2.0.2 on Galaxy S Plus running Android 2.3.6
  5. Waclaw Luczak 2012-06-13

    +1
  6. Opie Cyrus 2012-06-19

    Issue cannot be reproduced against current master@0629c0a11fd112cb5a326cdc161bbe8d09b3aad1 using both a Droid 2 (2.3) and Samsung Galaxy Tab (3.2). Upon taking photos during the first launch, the captured photo is stored to gallery and viewable. Test case:
       var win = Titanium.UI.createWindow({backgroundColor: 'red'});
       Titanium.Media.showCamera({
        
           success:function(event)
           {
               var cropRect = event.cropRect;
               var image = event.media;
        
               Ti.API.debug('Our type was: '+event.mediaType);
               if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
               {
                   var imageView = Ti.UI.createImageView({
                       width:win.width,
                       height:win.height,
                       image:event.media
                   });
                   win.add(imageView);
               }
               else
               {
                   alert("got the wrong type back ="+event.mediaType);
               }
           },
           cancel:function()
           {
           },
           error:function(error)
           {
               // create alert
               var a = Titanium.UI.createAlertDialog({title:'Camera'});
        
               // set message
               if (error.code == Titanium.Media.NO_CAMERA)
               {
                   a.setMessage('Please run this test on device');
               }
               else
               {
                   a.setMessage('Unexpected error: ' + error.code);
               }
        
               // show alert
               a.show();
           },
           saveToPhotoGallery:true,
           allowEditing:true,
           mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
       });
       win.open();
       
  7. Marcel Klapschus 2012-06-19

    *A bug is not solved just because the programmer cannot reproduce it, while it is confirmed that several users do have that bug. Try this: http://developer.appcelerator.com/question/138065/camera-causing-the-app-to-crash-randomly#comment-129771 It is working fine on 1.8.2, but does crash on 2.01 on the first start. So far, I experienced two different kind of behaviour with this bug: 1. App crashes with "unexpected error" message 2. After a few seconds of black screen, the app is showing a completely different view of my app It happens when i do a clean build of the app while my Samsung I9001 is connected via USB and I ran the app the first time. Once I switch to 2.0, and run again, everything is working fine. Another detail: It doesnt matter which cam-app i use (build-in Camera or ZoomFX), the error is the same.
  8. Neeraj Gupta 2012-06-19

    @Marcel - can you please confirm that you can reproduce this issue with the latest master (2.1.0) build?
  9. nilesh kashid 2012-06-19

    @Opie can u please build your application with titanium sdk 2.0.1 and test it on android device with android version 2.2. App will crash on first use. But if u use titanium sdk 1.8.1 and test it on same device it's working fine.
  10. Marcel Klapschus 2012-06-20

    @Neeraj I have this error with 2.0.1 GA2 and 2.0.2 GA. My studio tells me that 2.0.2 GA is the newest version. Where do you get 2.1.0???
  11. Neeraj Gupta 2012-06-20

    @marcel, @nilesh - Please try this issue with the latest build (choose master from the drop down box) from the link as we have fixed a very similar issue: http://builds.appcelerator.com.s3.amazonaws.com/index.html
  12. Marcel Klapschus 2012-06-20

    Tested with mobilesdk-2.1.0.v20120620184154-osx.zip. The bug seems to be gone now. Big thanks to the appcelerator staff for fixing that annoying bug!
  13. nilesh kashid 2012-06-21

    @Marcel can u please help me regarding: how to use this mobilesdk-2.1.0.v20120620184154-osx.zip. I have Titanium sdk 2.0.1GA2 and Google API android 2.2.
  14. Marcel Klapschus 2012-06-21

    @nilesh: In Titanium Studio, you click on "Help" and then on "Install Specific Titanium SDK" (think in older Studio version it was called something like "Install SDK from URL") ther you enter the downloadpath of the desired SDK File. For 2.1.0, you can take on of these: For OSX http://builds.appcelerator.com.s3.amazonaws.com/mobile/master/mobilesdk-2.1.0.v20120620184154-osx.zip For Windows: http://builds.appcelerator.com.s3.amazonaws.com/mobile/master/mobilesdk-2.1.0.v20120620184154-win32.zip For Linux http://builds.appcelerator.com.s3.amazonaws.com/mobile/master/mobilesdk-2.1.0.v20120620184154-linux.zip Afaik, those versions are only Release Candidates and no Stable releases, thats why they don't pop up in the normal update. Anyhow it took me some while to finde the download url, thanks to Neeraj for helping me out. And of course dont forget to choose 2.1.0 in your tiapp.xml and rebuild your project.
  15. nilesh kashid 2012-06-22

    @Marcel Thank you for information. I will try this
  16. Kazuya Chang 2012-06-26

    It works. Thanks to all Titanium staff. Titanium SDK --> 2.1.0, Android SDK --> 2.2
  17. Ariel Sztern 2012-08-19

    Hi, I'm using the last SDK (2.1.2.v20120816171609) and I still having this issue. From time to time (when I select a few photos from the picture gallery or just take a photo, the application is crashing. I'm looking for memory leaks but everything seems to be ok. The crash happens even before calling the success event. Here is a sample of the code: function chooseAPhoto() { Titanium.Media.openPhotoGallery({ success : function(event) { if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { addImage(event.media); } }, cancel : function() { }, error : function(error) { }, allowEditing : false, mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO] }); } Thanks, Ariel
  18. Neeraj Gupta 2012-08-19

    @Ariel - Can you reproduce this issue consistently with this test case? If yes, please provide the device information and we will attempt to try it on the same device.
  19. Ariel Sztern 2012-08-19

    Actually, yes and it's happening the same with the KitchenSink sample. I've a Samsung Galaxy S Thanks, Ariel
  20. Neeraj Gupta 2012-08-19

    Reopening based on the last comment.
  21. Ariel Sztern 2012-08-28

    Hi, I'm trying to deploy this by today. Is there any progress in fixing this bug? Regards, Ariel
  22. Waclaw Luczak 2012-08-28

    I've exactly the same problem with gallery. Tested on HTC Vision(HTC Desire Z). Thanks, Wacław
  23. Michael Belkin 2012-08-28

    I'm experiencing this as well.
  24. nilesh kashid 2012-08-28

    @Ariel Sztern,@Waclaw Luczak,@Michael Belkin can you plz tell me what android version you are using. plz test it on higher version of android (2.3.3>); and let me know whether it's working or not.....
  25. Ariel Sztern 2012-08-28

    I'm using a Samsung Galaxy S3 with android 4.0.3 and the problem persist. Thank you for your help, Ariel
  26. Ariel Sztern 2012-08-28

    I'm sorry android 4.0.4
  27. Waclaw Luczak 2012-08-30

    I'm using Android 2.3.3.
  28. Ariel Sztern 2012-09-02

    Is there any news regarding this issue? I wasn't able to deploy my app last week because of this bug. I really appreciate and support and feedback. Regards, Ariel
  29. Ariel Sztern 2012-09-10

    Max, could you please let me know when are you planing to solve this issue? This is stopping my whole application because this common feature it's not working. I've been wainting for this for the last 3 weeks, without any answer and I was expecting to have this solved with today's release. Thanks, Ariel
  30. Abdelrhman Halwani 2012-09-11

    Actually this bug made me frustrated cause, how could i finished the IPhone deployment and it is already accepted on the app store while i am still waiting to have the solution for this for more than three weeks since Mr. Ariel Sztern complained.
  31. Opie Cyrus 2012-09-18

    Tested KitchenSink (gallery and camera) and the test case provided by Ariel on Galaxy Nexus (4.1.1) and HTC Droid Incredible 2 (2.3.4). Was unable to reproduce against master(379ffe865ae784b560e7d230c45b078f45a5afaa) over more than a dozen separate attempts per device. Please provide the following to assist reproduction and investigation into this issue: 1) Full (zipped up) Titanium app that reproduces the issue 2) Full logcat output generated by running the provided test app on device. Please only provide log for a test run that results in a crash. 3) Device information (for the device used in steps #1 and #2) such as device model and exact software version 4) Exact reproduction steps
  32. Opie Cyrus 2012-09-21

    Closing for the time being as the issue cannot be reproduced internally and more information is needed.
  33. Ariel Sztern 2012-10-03

    Hi. The bug is still happening, these are the details: 1) Titanium App: I was able to replicate the bug using the last version of Kitchensink I found in github: (appcelerator-KitchenSink-2.1.2-2-g3a5099d) compiled with Titanium SDK 2.1.2GA and Android Runtime V8 I think I don't need to enclose it. 2) http://paste.plurk.com/show/1328314/ 3) Samsung Galaxy S3 (GT-I9300) with Android 4.0.4 Kernel Version: 3.0.15-833154-user 4) 1- Start the Kitchensink app 2- Select the Phone Tab 3- Select the item Camera 4- Camera Basic 5- Choose Samsung's default camera 6- Take photo 7- Confirm the selected photo 8- The app goes to the desktop and then restarts
  34. Jimmy Forrester-Fellowes 2012-10-04

    Sony Ericsson Xperia Play also force closing. showCamera() force closes with the following error: 10-04 16:30:07.881: E/AndroidRuntime(10268): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data dat=file:///sdcard/dcim/Camera/OL/tia54092358.jpg typ=image/jpeg (has extras) }} to activity {com.dn.mobile/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException openPhotoGallery() works fine.
  35. Ariel Sztern 2012-10-13

    Please, reopen this case because is not solved yet. Thanks,
  36. Ariel Sztern 2012-10-15

    I've found that the problem is related to the size of the picture you're selecting or taking (file size and MP). If I select a picture of 640x480 or under the 6MP, se function works fine. If the selection is done with a picture (existing or new one) of 6MP or more, the application cancels. Please, now you've an idea of what is happening, please try to solve this ASAP. Thank you so much, Ariel
  37. Rene Ziede 2012-12-06

    I have run into this issue as well while testing my application. Titanium SDK: 2.1.4.GA Phone: Sony Ericson Xperia Play Android Runtime: V8 OS: Android 2.3 Gingerbread Here is a pastebin with the segment of code being executed and the relevant logcat output from the device. http://pastebin.com/RzeUGC6x The code terminates before any of the call-backs are reached. The camera is opened and the crash occurs immediately after confirming the image taken. The message every time is: "Sorry! The application (process edu.ufl.ahc.ese) has stopped unexpectedly. Please try again", and the app closes and restarts.
  38. Eric Merriman 2013-01-16

    Reopening based on comments.
  39. Olga Romero 2013-01-16

    Since Kitchen Sink was modified and updated after the original bug was created, I cannot reproduce this issue. *Keeping it open for further investigation.* Tested with: Titanium Studio, build: 3.0.1.201212181159 Titanium SDK, build: 2.1.4.GA Titanium SDK, build: 3.0.0.GA Devices: GalaxyS3(4.0.4) Nexus7 (4.1.2) Droid3 (2.3.4)
  40. Rene Ziede 2013-01-17

    To clarify, of the physical devices I have tested, I only get this error on the Sony Ericson Xperia device. I have tested the above on Motorola, HTC, and LG devices with no difficulty.
  41. Daniel Sefton 2013-04-02

    Please watch TIMOB-12848. Let us know if you still have the issue after we solve 12848.
  42. Nezam Uddin 2013-06-19

    I can't believe that such a critical bug still happens to exist in the SDK while the appcelerator people are busy marketing their service as high quality cross platform development! Atleast you can release a temporal fix for our clients!
  43. Nezam Uddin 2013-06-25

    Why can't you people release an important fix for this bug!! I am still waiting for your supposed fix of 3.2.0! I downloaded the master and its not fixed in it.Cmon release a GA today!!!!!!
  44. Ingo Muschenetz 2013-06-25

    [~nezam] You may notice that we have (so far) been unable to reproduce this bug. It is very difficult to fix a bug we can't reproduce in house. Our next step is to try and get one of the devices that causes the problem, and we're getting a Sony Xperia. If you have an alternate suggestion, please let us know.
  45. Nezam Uddin 2013-06-26

    It fails on the following devices i tested with: Sony Xperia U Samsung Galaxy S III Samsung Nexus S All running ICS or above. Also restarts on emulators.Note this does not restart app all the time.But it does every once out of five times.
  46. Mike Butler 2013-11-21

    Kitchen Sink, Ti 3.1.3. Nexus 7 (4.3) Nexus 5 (4.4) Seriously guys, surely it can't be too hard to get hold of a nexus to test with your own sample code? This is a huge bug for us - we absolutely have to be able to chose images from the camera roll. Keep up the good work, but please, at the very least, change the status of this bug from "Resolved" so that it gets some attention. As another commenter pointed out, when you have so many people reporting the problem, then plainly there is a problem. Mike.
  47. Ingo Muschenetz 2013-11-21

    [~mike@teamworkpm] We now have multiple Xperias and Nexus(s). It's evidently not just solely an issue of having the specific device. Please note that this ticket is resolved as a _duplicate_ of TIMOB-12848. We're still working on it--it's just consolidated with another ticket.
  48. Mike Butler 2013-11-21

    Hi Ingo, Thanks for the pointer to the duplicate. Just a quick note : you left a comment a month ago on that bug saying that you just can't reproduce on any device. A strange quirk I just noticed, if the image in the gallery has ever been viewed by any app, _not just the Ti app_, so for example the Gallery app, then it will work okay in the Ti app (I know that sounds strange but I just tested it with Gallery and Kitchen Sink on a Nexus 7). So maybe that's making it harder for you to reproduce - maybe you've already viewed all of your images before with other apps. Again thanks for note on the duplicate. Mike.
  49. Lee Morris 2017-03-22

    Closing ticket as duplicate as the relevant ticket is linked above.

JSON Source