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

PlatformException(Failed to find configured root that contains /file:/storage/emulated/0/project/1590844068701.png, null, null) #19

Open
kashifg4171 opened this issue May 30, 2020 · 11 comments

Comments

@kashifg4171
Copy link

PlatformException(Failed to find configured root that contains /file:/storage/emulated/0/project/1590844068701.png, null, null)

I'm facing this exception while sharing image file. I had added path provider code in AndroidMinifest.xml file, make new file provider_path.xml in src/xml/...

Any solution please.

@marcLeeroy
Copy link

marcLeeroy commented Jun 3, 2020

The only way i fixed it is by making sure im saving the image to the Cache directory (with path_provider plugin) calling getExternalStorageDirectory then setting the following in my xml file (covering all bases)

<external-path name="external" path="." />
<external-files-path name="external_files" path="." />
<cache-path name="cache" path="." />
<external-cache-path name="external_cache" path="." />
<files-path name="files" path="." />

@00AhmedMokhtar00
Copy link

The only i fixed it is by making sure im saving the image to the Cache directory (with path_provider plugin) calling getExternalStorageDirectory then setting the following in my xml file (covering all bases)

<external-path name="external" path="." />
<external-files-path name="external_files" path="." />
<cache-path name="cache" path="." />
<external-cache-path name="external_cache" path="." />
<files-path name="files" path="." />

can you please explain where exactly you called getExternalStorageDirectory ?

@marcLeeroy
Copy link

marcLeeroy commented Jun 5, 2020

In my case i call before i save an image to disk (build my path with it as a save location). In your case you might be loading a file to share.

@iwishiwasaneagle
Copy link

One thing to note is that you need to pass the absolute file path to shareFile. This tripped me up for a while.

@anshgwash
Copy link

I'm trying to share a file from AppData using this. It works fine on iOS but gives this error when sharing on Android. Any idea how to share files from AppData?

@ghost
Copy link

ghost commented Aug 13, 2020

Another way to handle this would be to save your file in the getExternalStorageDirectory before sharing and pass the absolute path of that. Haven't tried it, but will post back the results.

If anyone has a work around for this please share.

@skionthursday
Copy link

I have a work around of this nature. see issue #27 for details.

@rihardsba
Copy link

rihardsba commented Aug 20, 2020

Had the same problem, this did the trick for me for iOS and Android devices. Thanks @Bretie for the suggestion

  var output;

  if (Platform.isIOS) {
    output = await getTemporaryDirectory();
  } else {
    output = await getExternalStorageDirectory();
  }
  final file = File("${output.path}/doc.pdf");
  await file.writeAsBytes(<Uint8List> file);

  try {
    await FlutterShare.shareFile(
      title: "Title",
      filePath: file.path,
    );
  } catch (err) {
    print(err);
  }

@muhd-ameen
Copy link

getExternalStorageDirectory

can't call getExternalStorageDirectory, can you please explain where did you called that function

@0llie
Copy link

0llie commented Nov 14, 2022

On Android (happily avoid platform specific handlings) I can use tmpDir = await getTemporaryDirectory() and File('${tmpDir.path}/kapitel.json') as well with only this rule
<cache-path name="cache" path="." />
The share dialogue opens and the file sharing works, despite the error log messages:

Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://de.someapp.provider/cache/kapitel.json from pid=20044, uid=1000 requires the provider be exported, or grantUriPermission()

@ron-diesel
Copy link

On Android (happily avoid platform specific handlings) I can use tmpDir = await getTemporaryDirectory() and File('${tmpDir.path}/kapitel.json') as well with only this rule <cache-path name="cache" path="." /> The share dialogue opens and the file sharing works, despite the error log messages:

Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://de.someapp.provider/cache/kapitel.json from pid=20044, uid=1000 requires the provider be exported, or grantUriPermission()

I have the same case, but the log with the exception seems to be a problem to me

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

No branches or pull requests

10 participants