Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRASH] When used in flutter, Fileprovider paths can be overwritten #162

Closed
MCOfficer opened this issue Jul 30, 2019 · 6 comments
Closed
Assignees
Labels

Comments

@MCOfficer
Copy link

MCOfficer commented Jul 30, 2019

Note: While this bug did affect me, i'm not sure if it is on you to fix it. cc @Sh1d0w , in case you feel responsible. I'm just filing it here to raise awareness, and to help others who have the same issue.

Describe the bug

We use this plug-in through multi_image_picker from flutter. When opening the camera, we got the following crash:

D/AndroidRuntime( 4819): Shutting down VM
E/AndroidRuntime( 4819): FATAL EXCEPTION: main
E/AndroidRuntime( 4819): Process: me.mcofficer.testapp, PID: 4819
E/AndroidRuntime( 4819): java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/DCIM/Camera/JPEG_20190730_085744_7657154079095321330.jpg
E/AndroidRuntime( 4819): at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:739)
E/AndroidRuntime( 4819): at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418)
E/AndroidRuntime( 4819): at com.sangcomz.fishbun.util.CameraUtil.takePicture(CameraUtil.java:41)
E/AndroidRuntime( 4819): at com.sangcomz.fishbun.ui.album.AlbumController.takePicture(AlbumController.java:132)
E/AndroidRuntime( 4819): at com.sangcomz.fishbun.ui.album.AlbumActivity$1.onClick(AlbumActivity.java:96)
E/AndroidRuntime( 4819): at android.view.View.performClick(View.java:6597)
E/AndroidRuntime( 4819): at android.view.View.performClickInternal(View.java:6574)
E/AndroidRuntime( 4819): at android.view.View.access$3100(View.java:778)
E/AndroidRuntime( 4819): at android.view.View$PerformClick.run(View.java:25885)
E/AndroidRuntime( 4819): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime( 4819): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4819): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 4819): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime( 4819): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 4819): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime( 4819): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process ( 4819): Sending signal. PID: 4819 SIG: 9
Lost connection to device.

To Reproduce
Steps to reproduce the behavior:

  1. Create a flutter app with an android module
  2. define an authority and file provider paths in the module's manifest. Make sure the authority matches your.flutter.app.provider, e.g. me.mcofficer.testapp.provider
  3. Implement multi_image_picker according to their instructions. Make sure to set enableCamera to true.
  4. Place a debug point on this line:
    uri = FileProvider.getUriForFile(activity,
  5. Open your app, make it open fishbun, and tap the camera. You should hit the debug point; Step into getUriForFile and see what getPathStrategy(context, authority) returns.

Expected behavior
The returned PathStrategy should be the one defined in FishBun's AndroidManifest.xml.
Once you resume execution, the camera should open.

Actual behavior
The returned PathStrategy contains the paths from your flutter app's module instead of those from FishBun. If these paths aren't the same by chance, android will most likely fail to find the intended image file within these paths, resulting in above crash.

Smartphone (please complete the following information):

  • Device: As far as we know, any Android 9 device or Emulator. Specifically, a TA-1095 was used.
  • OS: Android N or greater, so the android X compatibility kicks in.
  • Version: multi_image_picker currently uses 0.10.0, but 0.11.0 is also affected.

The workaround is to either include FishBun's provider path in your module's paths, or to rename your module's authority name so it doesn't exactly match the one fishbun uses.

The solution on fishbun's end might be to use a more distinct authority name, or perhaps check if that authority already exists.

@MCOfficer MCOfficer added the bug label Jul 30, 2019
@Sh1d0w
Copy link
Contributor

Sh1d0w commented Jul 30, 2019

Hey. I don’t think the issue is related to the Flutter plugin. No where in the doc is suggested to add a file provider it should work out of the box without it. See the example app https://github.com/Sh1d0w/multi_image_picker/blob/master/example/android/app/src/main/AndroidManifest.xml

The old doc where it was suggested was when the plugin used Matisse instead FishBun.

If this is fixed in FishBun I will update the plugin accordingly will follow up this issue.

@MCOfficer
Copy link
Author

MCOfficer commented Jul 30, 2019

Hey. I don’t think the issue is related to the Flutter plugin. No where in the doc is suggested to add a file provider it should work out of the box without it. See the example app https://github.com/Sh1d0w/multi_image_picker/blob/master/example/android/app/src/main/AndroidManifest.xml

thanks for jumping on this so quickly. just to clarify, your instructions aren't unclear - we require our own file provider for reasons unrelated to this package.

@sangcomz sangcomz self-assigned this Jul 30, 2019
@vivekkujur
Copy link

facing same issue

@sangcomz
Copy link
Owner

sangcomz commented Sep 2, 2019

@Sh1d0w @MCOfficer

I released version 0.11.1. Please check and let me know. Thank you.

@Sh1d0w
Copy link
Contributor

Sh1d0w commented Sep 29, 2019

@MCOfficer I've updated FishBun version in multi_image_picker can you check if it is fixed now?

@MCOfficer
Copy link
Author

@MCOfficer I've updated FishBun version in multi_image_picker can you check if it is fixed now?

took me long enough, but it seems like this is fixed. closing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants