Hi I'm currently experiencing error on starting an intent due to FileProvider causing NPE. I followed the steps provided here but I still got the error:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
I am not sure as well if the provider_paths.xml is being used here. Here's my code so far:
Manifest:
<application>... <provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider></application>
res/xml:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
code:
Uri uri=FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID+".provider", file);
the itself seems to be the cause of error here.