Skip to content Skip to sidebar Skip to footer

Fileprovider Error

https://developer.android.com/training/camera/photobasics.html All I am trying to do is take a picture with the Camera, save it and display it in an ImageView. I followed the andro

Solution 1:

I finally got it to work!

Remember to put the provider tag INSIDE the application tag in the manifest file - that was my mistake (my provider tag was OUTSIDE of the application tag), and the reason you get this error, which basically says it cannot find the definition of the Provider.

Also make sure you have the correct paths in the .xml file. Here is my version:

<?xml version="1.0" encoding="utf-8"?><pathsxmlns:android="http://schemas.android.com/apk/res/android"><external-pathname="my_images"path="Android/data/org.projects.cameraapp/files/Pictures" /></paths>

Of course you have to change the path for your own application.

My actual Provider then looks like this:

<providerandroid:name="android.support.v4.content.FileProvider"android:authorities="org.projects.cameraapp.fileprovider"android:exported="false"android:grantUriPermissions="true"><meta-dataandroid:name="android.support.FILE_PROVIDER_PATHS"android:resource="@xml/filepaths" /></provider>

Again, you'll need to change the authorities value in your own application.

You can see all the source at the GitHub repository from my original question.

Solution 2:

If someone is having hard time as me with support.v4.content.FileProvider you can replace it with this.

<providerandroid:name="androidx.core.content.FileProvider"android:authorities="com.camera.app.fileprovider"android:exported="false"android:grantUriPermissions="true"><meta-dataandroid:name="android.support.FILE_PROVIDER_PATHS"android:resource="@xml/file_paths"></meta-data></provider>

Solution 3:

I also forgot to put <provider> within <application>; I mistakenly put them on the same level which I have since fixed.

<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="zm.mytestapplication"><application...android:theme="@style/AppTheme"><providerandroid:name="android.support.v4.content.FileProvider"android:authorities="zm.mytestapplication.fileprovider"android:exported="false"android:grantUriPermissions="true"><meta-dataandroid:name="android.support.FILE_PROVIDER_PATHS"android:resource="@xml/file_paths"></meta-data></provider></application></manifest>

file_paths.xml

<?xml version="1.0" encoding="utf-8"?><pathsxmlns:android="http://schemas.android.com/apk/res/android"><external-pathname="my_images"path="Pictures/zm/" /></paths>

Post a Comment for "Fileprovider Error"