Android FileProvider相关 Failed to find configured root that contains
问题:
使用FileProvider构造SD卡中文件uri时异常
java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/840E-10F6/音乐/千里之外.mp3
at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:678)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)
解决方案:
provider_paths.xml 中增加 root-path 标签
<paths xmlns:android="http://schemas.android.com/apk/res/android"> <root-path name="root_path" path="." /> </paths>