FileProvider - 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/ in it, so the path attribute in your XML is invalid.

Replace res/xml/file_paths.xml with:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-files-path name="my_images" path="/" />
</paths>

UPDATE 2020 MAR 13

Provider path for a specific path as followings:

  • <files-path/> --> Context.getFilesDir()
  • <cache-path/> --> Context.getCacheDir()
  • <external-path/> --> Environment.getExternalStorageDirectory()
  • <external-files-path/> --> Context.getExternalFilesDir(String)
  • <external-cache-path/> --> Context.getExternalCacheDir()
  • <external-media-path/> --> Context.getExternalMediaDirs()

Ref: https://developer.android.com/reference/androidx/core/content/FileProvider


This may resolve everyones problem: All tags are added so you don't need to worry about folders path. Replace res/xml/file_paths.xml with:

<?xml version="1.0" encoding="utf-8"?>
<paths>
  <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="." />
</paths>

EDIT: 1st June 2021

We should use only specific path which we need. Try alternate path on your own and use which you needed.

See Accepted answer for more information: https://stackoverflow.com/a/42516202/4498813