My application keeps crashing and I get this error: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.example.android.provider
This is the code that's causing the error. Specifically, the photoURI
line:
photoFile?.also {
photoURI = FileProvider.getUriForFile(
Objects.requireNonNull(applicationContext),
"com.example.android.provider",
it
)
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
startActivityForResult(takePictureIntent, 1)
}
In my AndroidManifest.xml
I have this:
<provider
android:name="androidx.core.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>
In my provider_paths.xml
file I have this:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="external_files"
path="." />
</paths>
What is it that I'm doing wrong? I don't understand what's causing the error cause everything seems to be right.