java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:604)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:578)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:416)
at com.xiaoluobei.facedetection.view.activity.FaceBlackInsertOrUpdateActivity$3.onClick(FaceBlackInsertOrUpdateActivity.java:262)
at android.support.v7.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1067)
at android.widget.AdapterView.performItemClick(AdapterView.java:313)
at android.widget.AbsListView.performItemClick(AbsListView.jav
这个错多半是出在provider的包名部分写错了导致没找到报空了,从第4行的日志定位到FaceBlackInsertOrUpdateActivity.java类262行,代码是:
phototUri = FileProvider.getUriForFile(
context,
context.getPackageName() + ".fileprovider",
cameraPhoto);
打断点一看,context.getPackageName()得到的跟manifest得到的包名并不一致,费解,故代码改为:
phototUri = FileProvider.getUriForFile(
context,
"com.xiaoluobei.facedetection.fileproviders",
cameraPhoto);
好用了。
来源:CSDN
作者:Crystal_xing
链接:https://blog.csdn.net/Crystal_xing/article/details/86502861