{"action":"created","issue":{"url":"https://api.github.com/repos/react-community/react-native-image-picker/issues/836","repository_url":"https://api.github.com/repos/react-community/react-native-image-picker","labels_url":"https://api.github.com/repos/react-community/react-native-image-picker/issues/836/labels{/name}","comments_url":"https://api.github.com/repos/react-community/react-native-image-picker/issues/836/comments","events_url":"https://api.github.com/repos/react-community/react-native-image-picker/issues/836/events","html_url":"https://github.com/react-community/react-native-image-picker/issues/836","id":316037796,"number":836,"title":"App crash after clicking 'Take photo' (Android)","user":{"login":"appli-intramuros","id":33863546,"avatar_url":"https://avatars1.githubusercontent.com/u/33863546?v=4","gravatar_id":"","url":"https://api.github.com/users/appli-intramuros","html_url":"https://github.com/appli-intramuros","followers_url":"https://api.github.com/users/appli-intramuros/followers","following_url":"https://api.github.com/users/appli-intramuros/following{/other_user}","gists_url":"https://api.github.com/users/appli-intramuros/gists{/gist_id}","starred_url":"https://api.github.com/users/appli-intramuros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appli-intramuros/subscriptions","organizations_url":"https://api.github.com/users/appli-intramuros/orgs","repos_url":"https://api.github.com/users/appli-intramuros/repos","events_url":"https://api.github.com/users/appli-intramuros/events{/privacy}","received_events_url":"https://api.github.com/users/appli-intramuros/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-19T20:56:39Z","updated_at":"2018-04-24T20:39:59Z","closed_at":null,"author_association":"NONE","body":"### Description\r\n\r\nHello,\r\n\r\nSome Android devices (samsung A5, Android 7.0) crash just after clicking \"Take photo\" in the dialog box. (Choose picture from library works well.)\r\n\r\nPlease find the crash logs:\r\n```\r\nFatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.facebook.react.bridge.ReadableMap.hasKey(java.lang.String)' on a null object reference\r\n       at com.imagepicker.ImagePickerModule.parseOptions(ImagePickerModule.java:707)\r\n       at com.imagepicker.ImagePickerModule.launchCamera(ImagePickerModule.java:233)\r\n       at com.imagepicker.ImagePickerModule.launchCamera(ImagePickerModule.java:206)\r\n       at com.imagepicker.ImagePickerModule$2.onTakePhoto(ImagePickerModule.java:162)\r\n       at com.imagepicker.utils.UI$1.onClick(UI.java:54)\r\n       at android.support.v7.app.AlertController$AlertParams$3.onItemClick(AlertController.java:807)\r\n       at android.widget.AdapterView.performItemClick(AdapterView.java:343)\r\n       at android.widget.AbsListView.performItemClick(AbsListView.java:1664)\r\n       at android.widget.AbsListView$PerformClick.run(AbsListView.java:4075)\r\n       at android.widget.AbsListView$10.run(AbsListView.java:6557)\r\n       at android.os.Handler.handleCallback(Handler.java:751)\r\n       at android.os.Handler.dispatchMessage(Handler.java:95)\r\n       at android.os.Looper.loop(Looper.java:154)\r\n       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)\r\n       at java.lang.Thread.run(Thread.java:762)\r\n```\r\n\r\n### How to repeat issue and example\r\n\r\nHere is the source code I use to open the image picker dialog:\r\n```\r\nconst photoOptions = {\r\n      title: '',\r\n      cancelButtonTitle: 'Annuler',\r\n      takePhotoButtonTitle: 'Prendre une photo...',\r\n      chooseFromLibraryButtonTitle: 'Choisir une photo...',\r\n };\r\n\r\nshowImagePicker(photoOptions, response => {\r\n      if (!response.didCancel && !response.error && !response.customButton) {\r\n        const imageSource = {\r\n          uri: response.uri,\r\n          name: response.fileName ? response.fileName : 'image.JPG',\r\n          type: 'image/jpg',\r\n        };\r\n\r\n        this.setState({ imageSource });\r\n      }\r\n });\r\n```\r\n\r\n### Solution\r\n\r\nThe null pointer appears here in the image-picker source code (ImagePickerModule.java):\r\n```\r\nprivate void parseOptions(final ReadableMap options) {\r\n  noData = false;\r\n  if (options.hasKey(\"noData\")) {    **<==== HERE, options is null, but I can figure out why !?**\r\n    noData = options.getBoolean(\"noData\");\r\n  }\r\n  imageConfig = imageConfig.updateFromOptions(options);\r\n  pickVideo = false;\r\n  if (options.hasKey(\"mediaType\") && options.getString(\"mediaType\").equals(\"video\")) {\r\n    pickVideo = true;\r\n  }\r\n  videoQuality = 1;\r\n  if (options.hasKey(\"videoQuality\") && options.getString(\"videoQuality\").equals(\"low\")) {\r\n    videoQuality = 0;\r\n  }\r\n  videoDurationLimit = 0;\r\n  if (options.hasKey(\"durationLimit\")) {\r\n    videoDurationLimit = options.getInt(\"durationLimit\");\r\n  }\r\n}\r\n```\r\n\r\nIs it possible to add a NPE check on options variable ?\r\n\r\nThanks.\r\n\r\n### Additional Information\r\n\r\n* React Native version: 0.54.2\r\n* React Native Image Picker version: 0.26.7\r\n* Platform: Android\r\n* Development Operating System: MacOS High Sierra 10.13.4\r\n* Dev tools: Android Studio \r\n"},"comment":{"url":"https://api.github.com/repos/react-community/react-native-image-picker/issues/comments/384072394","html_url":"https://github.com/react-community/react-native-image-picker/issues/836#issuecomment-384072394","issue_url":"https://api.github.com/repos/react-community/react-native-image-picker/issues/836","id":384072394,"user":{"login":"appli-intramuros","id":33863546,"avatar_url":"https://avatars1.githubusercontent.com/u/33863546?v=4","gravatar_id":"","url":"https://api.github.com/users/appli-intramuros","html_url":"https://github.com/appli-intramuros","followers_url":"https://api.github.com/users/appli-intramuros/followers","following_url":"https://api.github.com/users/appli-intramuros/following{/other_user}","gists_url":"https://api.github.com/users/appli-intramuros/gists{/gist_id}","starred_url":"https://api.github.com/users/appli-intramuros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appli-intramuros/subscriptions","organizations_url":"https://api.github.com/users/appli-intramuros/orgs","repos_url":"https://api.github.com/users/appli-intramuros/repos","events_url":"https://api.github.com/users/appli-intramuros/events{/privacy}","received_events_url":"https://api.github.com/users/appli-intramuros/received_events","type":"User","site_admin":false},"created_at":"2018-04-24T20:39:58Z","updated_at":"2018-04-24T20:39:58Z","author_association":"NONE","body":"@skyforeverGE I don't get the point. Can you detail your solution ?\r\n"}}
{"actor":{"display_login":"appli-intramuros"}}