发布于 4年前

java.lang.IllegalArgumentException: Failed to find configured root 错误解析

1.

查看log 发现 这是在android8.1以上进行程序间文件共享使用FileProvider时出现的构造SD卡异常错误

Process: org.codeaurora.gallery, PID: 1305

05-10 15:40:10.911 1305 1305 E AndroidRuntime: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/4305-1612/MUTE_20180510_154005.mp4

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:712)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:401)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at com.android.gallery3d.app.MuteVideo$1$2.run(MuteVideo.java:130)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:790)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6518)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)

05-10 15:40:10.911 1305 1305 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

2 原因分析

结合Log 发现是共享SD卡发生了错误

3 解决方法

在file_paths.xml文件中添加root-path 标签

<path>

<root-path name="root_path" path="."/>

</path>

©2020 edoou.com   京ICP备16001874号-3