react-native-image-crop-picker
react-native-image-crop-picker copied to clipboard
Error: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
Version
"react-native": "^0.52.0", "react-native-image-crop-picker": "^0.19.1",
Platform
- Android
Manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
gradel dependencies { classpath 'com.android.tools.build:gradle:2.2.3' }
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
its same issue if use distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
Same issue here after upgrading React Native. Did you find a workaround / solution @riansyaaah?
@OzoTek i create new project React Native and move my script on old project to new project. That bad solution but its work for me
add this to your AndroidManifest.xml file
<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 add this to your android/app/main/res/xml/provider_paths.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>
I tried once more and finally got it work
- add this to your AndroidManifest.xml file (between the
<application>and</application>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 add this to your android/app/main/res/xml/provider_paths.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>
I used the above's code, but still have a error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute provider#android.support.v4.content.FileProvider@authorities value=(com.xxx.provider) from AndroidManifest.xml:39:13
is also present at Select:react-native-image-crop-picker:unspecified:15:13 value=(com.reactnative.ivpusic.imagepicker.provider)
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:37:7 to override
So you need add tools:replace="android:authorities" into <provider> tag
like this:
<provider
tools:replace="android:authorities"
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 add the name space for tools:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
...
>
I'm still getting the same behaviour using this solution
same here. Image is saved here: file:///data/user/0/com.mypet/cache/ReactNative-snapshot-image-164856113.jpg
The path attribute shares the images/ subdirectory of files/. The name attribute tells the FileProvider to add the path segment myimages to content URIs for files in the files/images/ subdirectory. https://developer.android.com/training/secure-file-sharing/setup-sharing.html
this confuse me in the documentation
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path path="com.mypet/" name="cache" />
</paths>
filepaths.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mypet">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.mypet.fileprovider"
android:grantUriPermissions="true"
android:exported="false"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
AndroidManifest.xml
https://developer.android.com/reference/android/support/v4/content/FileProvider.html#SpecifyFiles
same issue
same issue
Finally solved it..
In my case
Suggestion: add 'tools:replace="android:resource"' to
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"
tools:replace="android:resource"/> // add this line.
</provider>
+1
same issue
In my case it gives error on the camera plugin, so I change the xml value of the meta-data in provider to camera_provider_paths. Snippet as below:
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" /> </provider>
If you don't want to edit AndroidManifest.xml everytime you rebuilt, you may edit the config.xml with snippet below:
<config-file parent="./application" target="AndroidManifest.xml"> <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" /> </provider>
If you've migrated over to react >0.60, make sure you use androidx.core.content.FileProvider instead if android.support.v4.content.FileProvider causes crashes when you boot up your app.
tools:replace="android:authorities"
this solved my problem. Thanks!!!