0

I follow the Android Developers tutor for taking and saving a picture. The call to FileProvider.getUriForFile in the following code fragment produce runtime error.

Exception -

    Caused by: java.lang.IllegalArgumentException: Failed to find 
configured root that contains /storage/sdcard/Android
/data/com.example.myfirstapp/files/Pictures/JPEG_20161121_150916_-
1008254408.jpg

Java -

if (photoFile != null) {
                Uri photoURI = FileProvider.getUriForFile(this,
                        "com.example.myfirstapp.fileprovider",
                        photoFile);
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            }

Manifest.xml -

<provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.myfirstapp.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths"></meta-data>
    </provider>
Nayan Srivastava
  • 3,655
  • 3
  • 27
  • 49
Shai
  • 117
  • 6
  • 19
  • Please edit your question and provide the contents of your `file_paths.xml` file. Also, please show how you are creating the value for `photoFile`. – CommonsWare Nov 21 '16 at 15:27

1 Answers1

0

Seems like the problem was in defining the provider within the Manifest file.

Found a solution here ANSWER

Thanks to ImagineThat

Community
  • 1
  • 1
Shai
  • 117
  • 6
  • 19