[CRASH] When used in flutter, Fileprovider paths can be overwritten
See original GitHub issueNote: 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:
- Create a flutter app with an android module
- 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
- Implement multi_image_picker according to their instructions. Make sure to set
enableCamera
to true. - Place a debug point on this line: https://github.com/sangcomz/FishBun/blob/9c48062802588367eaecfd20e791d9bb04f0f144/FishBun/src/main/java/com/sangcomz/fishbun/util/CameraUtil.java#L41
- Open your app, make it open fishbun, and tap the camera. You should hit the debug point; Step into
getUriForFile
and see whatgetPathStrategy(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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
@Sh1d0w @MCOfficer
I released version 0.11.1. Please check and let me know. Thank you.
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.