Open EnduringBeta opened 1 year ago
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
over a year later I am encountering the exact same issue, adding the contents of their AndroidManifest.xml didnt work for me, so did anyone find a solution to this?
Did you define a FileProvider
in your AndroidManifest.xml
for your app package folders? https://developer.android.com/training/secure-file-sharing/setup-sharing#DefineProvider
The share_plus
package already provides one provider in the manifest, but it is only configured to handle the cached folder for share plus, i.e. share_plus/
inside the app temporal files, for when users share files stored temporally when using XFile.fromData
. (this maybe needs better documentation)
I think you have to define a provider for your own paths as well.
Yes I have defined such file provider like in the documentation. The issue I think to see is that in my Exception it says that the plus.share.ShareFileProvider does not have the permissions, so I dont think defining a FileProvider in my AndroidManifest wont help there?
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths"/> </provider>
`<?xml version="1.0" encoding="utf-8"?>
`
_E/DatabaseUtils( 9066): java.lang.SecurityException: Permission Denial: writing dev.fluttercommunity.plus.share.ShareFileProvider uri content://de.randomtick.orbit.flutter.share_provider/cache/sharedimage.png from pid=7308, uid=10120 requires the provider be exported, or grantUriPermission()
For what I can see, the package calls to grantUriPermission
, which is what the error recommends: https://github.com/fluttercommunity/plus_plugins/blob/f1c3462a2b798ed4ea9356f71bde922a88a36da7/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt#L151
Is there a chance you can provide an example project where to reproduce this issue?
https://github.com/christofkern/shareplus_issue
i just uploaded one, really dumbed down from what i want it to use, but error remains
I ran the example on my Pixel 5 and shared the picture with Telegram. Both the text and the image were shared successfully, and I didn't see any console errors. Are there any other conditions that cause the bug?
My logs
Syncing files to device Pixel 5...
I/flutter (11329): /data/user/0/com.example.shareplus_issue/cache/shared_image.png
D/CompatibilityChangeReporter(11329): Compat change id reported: 160794467; UID 10608; state: ENABLED
I/flutter (11329): /data/user/0/com.example.shareplus_issue/cache/shared_image.png
Application finished.
yeah the error only comes up when pressing the edit button in the share popup, like originally described in this issue
Ok, I have completely missed the "Edit button" part. I don't see any Edit button either, is that an option on the share sheet? It does not appear on my Android version. Could you share a screenshot of that?
Nevertheless, I start to connect some dots. A 3rd app tries to edit the file shared from the app directly, which causes this to crash. As I understand, the permissions are set correctly to allow that, but other than that I am not sure what could be wrong.
if there is an option to get rid of that one, I would also not mind, as that feature isnt really necessary. But since it is there and leads to a crash I somehow have to adress it
What Android version do you have?
The emulator is 33
interestingly enough its not there on my own smartphone which is android 11 (30).
Yep, I can reproduce the issue now, I will reopen the ticket.
My first idea is to modify the plugin and also add Write permissions here to this line: https://github.com/fluttercommunity/plus_plugins/blob/f1c3462a2b798ed4ea9356f71bde922a88a36da7/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt#L127
I am not able to figure it out.
But there are a couple of things that don't add up:
The file URI is content://com.example.shareplus_issue.flutter.share_provider/cache/shared_image.png
.
The plugin setups the following filepaths:
<cache-path name="cache" path="share_plus/" />
The provider authority used by the plugin is <app id>.flutter.share_provider
.
All of this seem to be correct, as the plugin always copies all files to the cache before sharing them.
Then, I am pretty sure that adding the following to the AndroidManifest in fact does nothing and can be removed:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"
/>
</provider>
I tried several things and none worked, but changing the above line to use write permissions did something:
shareIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
When I tap on edit nothing happens, but also the app doesn't crash (???) the other share options still work (e.g. share to Google search image), still not sure why is that making a difference. But if you want to test, I guess you can clone the repo and set the package path, e.g.
share_plus:
path: ../../fluttercommunity/plus_plugins/packages/share_plus/share_plus/
and change that line in the kt file.
Let me know if you try.
Same behaviour for me. Does not crash anymore, even though the edit button does nothing. Thanks! This is very fine for me for now
It is still a very buggy behavior, and I even wonder if this is an issue on Android OS itself. At least it helped to investigate further.
Platform
Android 12
Plugin
share_plus
Version
6.3.0
Flutter SDK
3.3.0
Steps to reproduce
Steps
screenshot
) on an Android device.Thoughts
This app stores the screenshot PNG file in the temporary directory. There are SO posts and resources for this exception, but few focused on Flutter. The ones that are encourage adding a
<provider>
tag in theAndroidManifest.xml
, which I was unsuccessful at doing properly.When I looked at share_plus's AndroidManifest.xml, it has a
<provider>
, though for a sub directory. I'm skeptical I should be duplicating or near-duplicating this.I'm new to this aspect, so I'm open to this not being a bug at all. If it's not, though, I believe my confusion might deserve a documentation update to guide future folks.
Code Sample
Logs
Flutter Doctor
Checklist before submitting a bug
flutter pub upgrade
flutter clean