[ https://issues.apache.org/jira/browse/CB-6875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14046202#comment-14046202 ]
ASF GitHub Bot commented on CB-6875: ------------------------------------ Github user asfgit closed the pull request at: https://github.com/apache/cordova-plugin-camera/pull/29 > navigator.camera.getPicture throws exception and crashes app on Android > ----------------------------------------------------------------------- > > Key: CB-6875 > URL: https://issues.apache.org/jira/browse/CB-6875 > Project: Apache Cordova > Issue Type: Bug > Components: Plugin Camera > Affects Versions: 3.4.0 > Environment: Android 4.1.2, HTC Desire 500 (without SDCard!) > Reporter: Dominik Pesch > Labels: bug,, exception > > On one of our test devices (HTC Desire 500 with Android 4.1.2) our app > crashes when getting a picture from the camera. As [~wedgberto] describes: > the exception will be thrown if no SD card is mounted. But the camera app > stores the photo and you can get it later from the photo album. (please see > https://issues.apache.org/jira/browse/CB-5133?focusedCommentId=13874707&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13874707) > The HTC throws an IllegealStateException in > {code:title=CameraLauncher.java#getUriFromMediaStore()|borderStyle=solid} > try { > uri = > this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, > values); > } catch (UnsupportedOperationException e) { > // ... > } > // ... > {code} > The IllegalStateException won't be catched and the app will be killed: > {noformat} > 06-04 10:56:43.800: E/JHEAD(2816): can't open > '/data/data/com.example.package/cache/.Pic.jpg' > 06-04 10:56:43.830: W/dalvikvm(2816): threadid=1: thread exiting with > uncaught exception (group=0x40cc7600) > 06-04 10:56:43.850: E/AndroidRuntime(2816): FATAL EXCEPTION: main > 06-04 10:56:43.850: E/AndroidRuntime(2816): java.lang.RuntimeException: > Failure delivering result ResultInfo{who=null, request=34, result=-1, > data=null} to activity > {com.example.package/com.example.package.Finanzchecker}: > java.lang.IllegalStateException: Unable to create new file: > /storage/sdcard0/DCIM/Camera/1401872203812.jpg > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.ActivityThread.deliverResults(ActivityThread.java:3660) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.ActivityThread.handleSendResult(ActivityThread.java:3710) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.ActivityThread.access$1100(ActivityThread.java:151) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.os.Handler.dispatchMessage(Handler.java:99) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.os.Looper.loop(Looper.java:155) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.ActivityThread.main(ActivityThread.java:5536) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > java.lang.reflect.Method.invokeNative(Native Method) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > java.lang.reflect.Method.invoke(Method.java:511) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1074) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > dalvik.system.NativeStart.main(Native Method) > 06-04 10:56:43.850: E/AndroidRuntime(2816): Caused by: > java.lang.IllegalStateException: Unable to create new file: > /storage/sdcard0/DCIM/Camera/1401872203812.jpg > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.os.Parcel.readException(Parcel.java:1442) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.content.ContentProviderProxy.insert(ContentProviderNative.java:482) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.content.ContentResolver.insert(ContentResolver.java:874) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > org.apache.cordova.camera.CameraLauncher.getUriFromMediaStore(CameraLauncher.java:737) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:382) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:624) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:897) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.Activity.dispatchActivityResult(Activity.java:5275) > 06-04 10:56:43.850: E/AndroidRuntime(2816): at > android.app.ActivityThread.deliverResults(ActivityThread.java:3656) > 06-04 10:56:43.850: E/AndroidRuntime(2816): ... 11 more > 06-04 11:01:43.940: D/Process(2816): killProcess, pid=2816 > {noformat} > We've catched {{RuntimeExcpetion}} instead of > {{UnsupportedOperationException}} to catch also the {{IllegalStateException}} > and got a follow up {{NullPointerException}} in > {{processResultFromCamera(CameraLauncher.java:384)}} from > {{FileHelper.getRealPath(FileHelper.java:80)}}. After fixing this too, the > app won't be killed anymore. > We've tested also other apps (like the twitter app) which can't get the photo > from the camera too. But they won't crash/be killed. > I've created a pull request: > https://github.com/apache/cordova-plugin-camera/pull/29 -- This message was sent by Atlassian JIRA (v6.2#6252)