React-native-image-crop-picker: Android: ImagePicker.openCamera throws an error.

Created on 30 Apr 2018  路  2Comments  路  Source: ivpusic/react-native-image-crop-picker

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.19.3
  • react-native v0.53.0

Platform

Tell us to which platform this issue is related

  • Android

Expected behaviour

When calling ImagePicker.openCamera function, camera opens and allows to take a picture and crop it.

Actual behaviour

When calling ImagePicker.openCamera function, camera doesn't open and an error is thrown
Error: Failed to find configured root that contains /storage/emulated/0/Pictures/image-5d11ba49-be20-4bff-886a-1521499286f65949597546542086956.jpg

Steps to reproduce

  1. Install react-native-image-crop-picker

  2. Call ImagePicker.openCamera function

Attachments

https://github.com/ivpusic/react-native-image-crop-picker/blob/master/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java#L304 this is the line that fails.

Hello! For some time I've been using react-native-image-crop-picker without any issues (thanks for your great work), but now, I stumbled upon some kind of regression which doesn't allow me to take pictures anymore. The error I posted is basically all that's there. It is thrown When ImagePicker.openCamera is called. Here's a piece of my build.gradle setup:

android {
    compileSdkVersion 26
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.myid.android"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 7
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
}

any help would be highly appreciated since this issue prevents me from app release.
Thanks in advance!

Most helpful comment

Of course, I found a solution after hours of trying and finally posting here. For anyone having this problem in the future, adding this to AndroidManifest.xml (make sure that you place it in tags!!)

<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>

and under android/app/src/res/xml/provider_paths.xml set

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

and it should be all good.

All 2 comments

Of course, I found a solution after hours of trying and finally posting here. For anyone having this problem in the future, adding this to AndroidManifest.xml (make sure that you place it in tags!!)

<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>

and under android/app/src/res/xml/provider_paths.xml set

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

and it should be all good.

@brzezinskip thanks man, I already had a provider because I use react-native-sahre.

adding <external-path name="external_files" path="."/> to my filepaths.xml file fixed this issue for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xuchao321 picture xuchao321  路  3Comments

sergiulucaci picture sergiulucaci  路  3Comments

manojshrimalla picture manojshrimalla  路  3Comments

equesteo picture equesteo  路  3Comments

fmcruz picture fmcruz  路  3Comments