Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.83k stars 2.14k forks source link

Caused by: java.lang.IllegalStateException: Reply already submitted #581

Open gabrielziegler3 opened 4 years ago

gabrielziegler3 commented 4 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Launching lib/main.dart on MI 8 in debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
I/Timeline(  752): Timeline: Activity_launch_request time:677379572 intent:Intent { act=android.intent.action.GET_CONTENT typ=image/* }
I/ample.smartmea(  752): ProcessProfilingInfo new_methods=589 is saved saved_to_disk=1 resolve_classes_delay=8000
W/Activity(  752): Slow Operation: Activity com.example.smartmeat/.MainActivity onActivityResult took 147ms
W/1.gpu   (  752): type=1400 audit(0.0:823222587): avc: denied { search } for name="ctx" dev="debugfs" ino=15919 scontext=u:r:untrusted_app:s0:c123,c257,c512,c768 tcontext=u:object_r:qti_debugfs:s0 tclass=dir permissive=0
I/Timeline(  752): Timeline: Activity_launch_request time:677391411 intent:Intent { cmp=com.example.smartmeat/com.yalantis.ucrop.UCropActivity (has extras) }
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752): Failed to handle method call
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.smartmeat/com.yalantis.ucrop.UCropActivity}; have you declared this activity in your AndroidManifest.xml?
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2020)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1679)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.app.Activity.startActivityForResult(Activity.java:4651)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.app.Activity.startActivityForResult(Activity.java:4609)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at vn.hunghd.flutter.plugins.imagecropper.ImageCropperDelegate.startCrop(ImageCropperDelegate.java:86)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin.onMethodCall(ImageCropperPlugin.java:42)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.os.Looper.loop(Looper.java:165)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at android.app.ActivityThread.main(ActivityThread.java:6806)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/MethodChannel#plugins.hunghd.vn/image_cropper(  752):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
D/AndroidRuntime(  752): Shutting down VM
E/AndroidRuntime(  752): FATAL EXCEPTION: main
E/AndroidRuntime(  752): Process: com.example.smartmeat, PID: 752
E/AndroidRuntime(  752): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=69, result=0, data=null} to activity {com.example.smartmeat/com.example.smartmeat.MainActivity}: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(  752):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4419)
E/AndroidRuntime(  752):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4461)
E/AndroidRuntime(  752):    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
E/AndroidRuntime(  752):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/AndroidRuntime(  752):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/AndroidRuntime(  752):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
E/AndroidRuntime(  752):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(  752):    at android.os.Looper.loop(Looper.java:201)
E/AndroidRuntime(  752):    at android.app.ActivityThread.main(ActivityThread.java:6806)
E/AndroidRuntime(  752):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(  752):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/AndroidRuntime(  752):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
E/AndroidRuntime(  752): Caused by: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(  752):    at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:151)
E/AndroidRuntime(  752):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/AndroidRuntime(  752):    at vn.hunghd.flutter.plugins.imagecropper.ImageCropperDelegate.onActivityResult(ImageCropperDelegate.java:101)
E/AndroidRuntime(  752):    at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:204)
E/AndroidRuntime(  752):    at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:132)
E/AndroidRuntime(  752):    at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
E/AndroidRuntime(  752):    at android.app.Activity.dispatchActivityResult(Activity.java:7590)
E/AndroidRuntime(  752):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4412)
E/AndroidRuntime(  752):    ... 11 more
I/Process (  752): Sending signal. PID: 752 SIG: 9
Lost connection to device.

What is the expected behavior?

Crop the image and not crash

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Use the following Crop Image Class

class _CropImageState extends State<CropImage> {
  Image imageCropped;
  Future<Null> _cropImage(File imageFile) async {
    File croppedFile = await ImageCropper.cropImage(
      sourcePath: imageFile.path,
      // ratioX: 1.0,
      // ratioY: 1.0,
      maxWidth: 512,
      maxHeight: 512,
      // toolbarTitle: "Smart Meat Crop",
      // toolbarColor: Colors.white,
    );
    print("####################### Cropping image");
    setState(() {
      print("####################### image cropped!!");
      imageCropped = Image.file(
        croppedFile,
        fit: BoxFit.cover,
      );
    });
  }

using the following function to get image

  Future getImage() async {
    var image = await ImagePicker.pickImage(source: ImageSource.camera);

    setState(() {
      if (image != null)
      Navigator.of(context)
          .push(MaterialPageRoute(builder: (context) => CropImage(image)));
    });
  }

Which versions of uCrop, and which Android API versions are affected by this issue? Did this work in previous versions of uCrop?

Flutter 1.9.1+hotfix.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision 2d2a1ffec9 (6 weeks ago) • 2019-09-06 18:39:49 -0700 Engine • revision b863200c37 Tools • Dart 2.5.0 imageCropper: 1.0.2

Marina24 commented 4 years ago

Hi, @gabrielziegler3 You should add UCropActivity class to the AndroidManifest.xml file. It's led to the second exception.