App crash with error: Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
See original GitHub issueDescription
After invoking mutliple times ImagePicker.showImagePicker() my react-native based app crashed with the following error: Illegal callback invocation from native module. This callback type only permits a single invocation from native code. Stack tracke is attached below:
com.facebook.react.bridge.CallbackImpl.invoke CallbackImpl.java:30
com.imagepicker.ResponseHelper.invokeResponse ResponseHelper.java:76
com.imagepicker.ResponseHelper.invokeCustomButton ResponseHelper.java:56
com.imagepicker.ImagePickerModule.invokeCustomButton ImagePickerModule.java:497
com.imagepicker.ImagePickerModule$2.onCustomButton ImagePickerModule.java:193
com.imagepicker.utils.UI$1.onClick UI.java:66
android.support.v7.app.AlertController$AlertParams$3.onItemClick AlertController.java:1045
android.widget.AdapterView.performItemClick AdapterView.java:310
android.widget.AbsListView.performItemClick AbsListView.java:1145
android.widget.AbsListView$PerformClick.run AbsListView.java:306
android.widget.AbsListView$3.run AbsListView.java:3903
android.os.Handler.handleCallback Handler.java:739
android.os.Handler.dispatchMessage Handler.java:95
android.os.Looper.loop Looper.java:148
com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run MessageQueueThreadImpl.java:194
java.lang.Thread.run Thread.java:818
How to repeat issue and example
Click many times on e.g buttom that invokes ImagePicker.showImagePicker()
Solution
Currently no idea how ti fix it
Additional Information
- React Native version: 0.48.3
- Platform: Android
- Development Operating System: Windows
- Dev tools: Android Studio and Atom
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:18
Top Results From Across the Web
React Native callback type only permits a single invocation ...
A ReactNative Promise object, like a JavaScript Promise, can only be called once. If you want to send something multiple times from a...
Read more >Calling a callback multiple times in a React Native module
This callback type only permits a single invocation from native code.” In React Native, a native module callback can only be called once,...
Read more >Illegal callback invocation from native module ... - Issuehunt
Crash with error Illegal callback invocation from native module. This callback type only permits a single invocation from native code when you cancel ......
Read more >Getting "Illegal callback invocation from native module. This ...
This callback type only permits a single invocation from native code"-React Native. Search.
Read more >Secure Coding Guidelines for Java SE - Oracle
Java programs and libraries check for illegal state at the earliest opportunity ... To offer some of these protections during the invocation of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can reproduce this by calling showImagePicker twice.
The issue is callback from second call replaced the first one, therefore when both dialog of them have been pressed, it will called twice.
If you put
ImagePicker.showImagePicker
inonPress
and use double tap the button it is possible thatImagePicker.showImagePicker
will be called twice.My workaround is add a flag to stop it being called again until the dialog is dismissed.
@cma00000 thanks for the suggestion.
I ended up using the PermissionsAndroid module to request multiple permissions before invoking ImagePicker.showImagePicker. Here’s a slightly different example from the one @cma00000 listed above if anyone’s interested: