[Android] java.lang.IllegalStateException: Reply already submitted
Bevantos opened this issue · 5 comments
Repro steps:
Run an app that uses contacts_service and image_picker, then
1.) Get a Contact using "final Contact? contact = await ContactsService.openDeviceContactPicker();"
2.) Get an image from the gallery using " Uint8List bytesImage =await pickImage(ImageSource.gallery, context);"
3.) After image is selected, App crashes.
Note: Crashes only on Android, not on iOS.
Note: Crash happens only if contact has been picked before. If image is picked immediately there is no crash.
Note: Workaround to prevent crash: Comment out line 267 "this.result.success(result);" in ContactsServicePlugin.java
contacts_service: version 0.6.3
You can find output of flutter doctor and logs below.
Excerpt of crash log (full log below)
D/AndroidRuntime(12318): Shutting down VM
E/AndroidRuntime(12318): FATAL EXCEPTION: main
..E/AndroidRuntime(12318): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2342, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:83 flg=0x1 }} to activity {removed}.
..
E/AndroidRuntime(12318): Caused by: java.lang.IllegalStateException: Reply already submitted
...
E/AndroidRuntime(12318): at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$BaseContactsServiceDelegate.finishWithResult(ContactsServicePlugin.java:267)
E/AndroidRuntime(12318): at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$BaseContactsServiceDelegate.onActivityResult(ContactsServicePlugin.java:302)
--
[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-arm, locale de-DE)
Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.72.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
--
...
D/permissions_handler(12318): No android specific permissions needed for: 9
D/AndroidRuntime(12318): Shutting down VM
E/AndroidRuntime(12318): FATAL EXCEPTION: main
E/AndroidRuntime(12318): Process: removed, PID: 12318
E/AndroidRuntime(12318): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2342, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:83 flg=0x1 }} to activity {removed*****.MainActivity}: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(12318): at android.app.ActivityThread.deliverResults(ActivityThread.java:5368)
E/AndroidRuntime(12318): at android.app.ActivityThread.handleSendResult(ActivityThread.java:5407)
E/AndroidRuntime(12318): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)
E/AndroidRuntime(12318): at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
E/AndroidRuntime(12318): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(12318): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(12318): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)
E/AndroidRuntime(12318): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(12318): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(12318): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(12318): at android.app.ActivityThread.main(ActivityThread.java:7870)
E/AndroidRuntime(12318): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12318): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(12318): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/AndroidRuntime(12318): Caused by: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(12318): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:430)
E/AndroidRuntime(12318): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:267)
E/AndroidRuntime(12318): at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$BaseContactsServiceDelegate.finishWithResult(ContactsServicePlugin.java:267)
E/AndroidRuntime(12318): at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$BaseContactsServiceDelegate.onActivityResult(ContactsServicePlugin.java:302)
E/AndroidRuntime(12318): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:805)
E/AndroidRuntime(12318): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:428)
E/AndroidRuntime(12318): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:807)
E/AndroidRuntime(12318): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:724)
E/AndroidRuntime(12318): at android.app.Activity.dispatchActivityResult(Activity.java:8388)
E/AndroidRuntime(12318): at android.app.ActivityThread.deliverResults(ActivityThread.java:5361)
E/AndroidRuntime(12318): ... 13 more
I/Process (12318): Sending signal. PID: 12318 SIG: 9
Lost connection to device.
Exited
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Same Issue is appearing in my released app. This happens if select contact from phone and then open image picker and on select image app crashes. In successful use case on Selection the picked image goes to image cropper.
I am using
contacts_service: ^0.6.3
image_picker: ^0.8.6
image_cropper: ^3.0.1
Exception java.lang.RuntimeException:
at android.app.ActivityThread.deliverResults (ActivityThread.java:5078)
at android.app.ActivityThread.handleSendResult (ActivityThread.java:5120)
at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2199)
at android.os.Handler.dispatchMessage (Handler.java:112)
at android.os.Looper.loop (Looper.java:216)
at android.app.ActivityThread.main (ActivityThread.java:7625)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)
Caused by java.lang.IllegalStateException: Reply already submitted
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply (DartMessenger.java)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success (MethodChannel.java)
at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$BaseContactsServiceDelegate.finishWithResult (ContactsServicePlugin.java)
at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$BaseContactsServiceDelegate.onActivityResult (ContactsServicePlugin.java)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult (FlutterEngineConnectionRegistry.java)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult (FlutterEngineConnectionRegistry.java)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult (FlutterActivityAndFragmentDelegate.java)
at io.flutter.embedding.android.FlutterActivity.onActivityResult (FlutterActivity.java)
at android.app.Activity.dispatchActivityResult (Activity.java:7797)
at android.app.ActivityThread.deliverResults (ActivityThread.java:5071)
@Bevantos & @usamamanzoor07 Can I know , did you guys found any solution?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.