question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to find configured root that contains

See original GitHub issue

Hi. I’m running into this error when trying to make use of your Library. I combining this library with react-native-document-picker. I have in my android/app/src/main/res/xml file the following code:

<?xml version='1.0' encoding='utf-8'?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="files" path="/" />
    <external-files-path name="external_files" path="" />
    <external-path name="external" path="." />
    <cache-path name="cache" path="/" />
</paths>

Also, in my AndroidManifest.xml file, I have:

<provider
        android:name="com.vinzscam.reactnativefileviewer.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/file_viewer_provider_paths"
        />
      </provider>

Library is linked as directed in the docs. In my code, after getting the response object returned by react-native-document-picker, I am passing the uri as an argument to the open method:

const resFile = await documentPicker(['images'], {maxWidth: 250}) // This is a utility method that abstracts certain implementations, but functionality is same as regular documentPicker
if (resFile) {
  FileViewer.open(resFile.uri)
    .then(() => { 
        //do something awesome here 
    })
    .catch(error => {
        console.log(error) // This bit prints out the `Failed to find configured root that contains` errors
    })
}

React Native version: 0.59.9 React Native File Viewer version: 2.0.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arcollectorcommented, Mar 18, 2020

you need to remove the filePath.replace('file://', '')

0reactions
Malik-Usman17commented, Jan 1, 2022

hey @vinzscam hope you are fine, I’m still facing the same issue, can you or anyone here help me to solve this issue.

My Packages Version: react-native-file-viewer": “^2.1.5” “react”: “17.0.2” “react-native”: “0.66.0”

Read more comments on GitHub >

github_iconTop Results From Across the Web

IllegalArgumentException: Failed to find configured root ...
Your file is stored under getExternalFilesDir() . That maps to <external-files-path> , not <files-path> . Also, your file path does not contain images/...
Read more >
Android: FileProvider IllegalArgumentException Failed to find ...
Android : Android: FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4 ...
Read more >
FileProvider Issue: Failed to find configured root that contains
Failed to find configured root that contains /external_files/test.txt. My react-native use of the Share library looks this way:.
Read more >
Android Question Failed to find configured root - B4X
Hello, I'm having trouble with this line of code: Sub CreateFileProviderUri (Dir As String, FileName As String) As Object Dim FileProvider ...
Read more >
Android: FileProvider IllegalArgumentException ... - iTecNote
I am trying to use FileProvider to play a video from private path.Facing java.lang.IllegalArgumentException: Failed to find configured root that contains ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found