React-native-image-crop-picker: Manifest merge errors when using own FileProvider (react-native-share)

Created on 8 Jun 2018  路  3Comments  路  Source: ivpusic/react-native-image-crop-picker

I've faced this issue when I tried to install react-native-share while having react-native-image-crop-picker installed.
I've already solved this by my side but it can be solved by making minor changes in the library.

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

  • Android

Expected behaviour

Android app building without errors

Actual behaviour

Build error:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

Steps to reproduce

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

  2. install react-native-share

  3. build android app

Now, to fix this issue I had to create a subclass of FileProvider and point my AndroidManifest provider tag to it instead of android.support.v4.content.FileProvider

provider needed by react-native-share that you have to add into your projects AndroidManifest:
(located at android/app/src/main/AndroidManifest.xml inside application tag)

<provider
          android:name=".MyFileProvider" // this was pointing to 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" />
      </provider>

filepaths.xml (located at android/app/src/main/res/xml/filepaths.xml)

<?xml version="1.0" encoding="utf-8"?>
  <paths xmlns:android="http://schemas.android.com/apk/res/android">
      <external-path name="myexternalimages" path="Download/" />
      <external-path name="external_files" path="."/> // without this, openCamera falls into catch
  </paths>

MyFileProvider.java (located at android/app/src/main/java/com/YOUR_PROJECT/MyFileProvider.java

package com.YOUR_PROJECT;

import android.support.v4.content.FileProvider;

public class MyFileProvider extends FileProvider {
}

I found the solution in this github issue and the solution of the libraries maintainer in this SO question.

All this library has to do is to follow the steps above in the libraries android project and future generations won't face this issue when using react-native-share with this library together.

Most helpful comment

xmlns:tools="http://schemas.android.com/tools"
..........
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false">
android:name="android.support.FILE_PROVIDER_PATHS"
tools:replace="android:resource"//------------------------------add this line
android:resource="@xml/filepaths" />

I don't know well how tools:replace is working but build error is disappeared by adding this line.

All 3 comments

Woops, reopening so the maintainers won't overlook this. Can be closed when noticed by maintainers.

xmlns:tools="http://schemas.android.com/tools"
..........
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false">
android:name="android.support.FILE_PROVIDER_PATHS"
tools:replace="android:resource"//------------------------------add this line
android:resource="@xml/filepaths" />

I don't know well how tools:replace is working but build error is disappeared by adding this line.

Build error disappeared, but the image crop picker is not working now. The FileProvider in my application works fine

Was this page helpful?
0 / 5 - 0 ratings