错误日志:
2019-03-13 14:12:19.748 26138-26138/com.gdvictor.ivhelmet E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gdvictor.ivhelmet, PID: 26138
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
at android.app.ActivityThread.installProvider(ActivityThread.java:5858)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:608)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:579)
at android.support.v4.content.FileProvider.attachInfo(FileProvider.java:392)
at android.app.ActivityThread.installProvider(ActivityThread.java:5855)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
解决方案:
<provider .... /> 习惯性的使用这种方式结束 provider, 导致 <meta-data 没有被包含到 provider中,(细节问题)
报错前:
<provider
android:authorities="com.gdvictor.ivhelmet.fileprovider"
android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true"/>
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
解决后:
<provider
android:authorities="com.gdvictor.ivhelmet.fileprovider"
android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
网上其他解决方案参考:
1.https://stackoverflow.com/questions/45973746/missing-android-support-file-provider-paths-meta-data
自动安装参考博客:
https://www.jianshu.com/p/c58aa241688c