I'm trying to use a library that has this in its AndroidManifest.xml:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.imagepicker.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
I have the same tag in my app's AndroidManifest.xml:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="@string/FileProviderAuthority"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
So it obviously gives a Manifest merger error:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
Which suggests to "add 'tools:replace="android:authorities"' to element at AndroidManifest.xml to override".
So I add tools:replace="android:authorities"
like this, in my app's AndroidManifest.xml:
<application
tools:replace="android:authorities"
android:name=".appcontroller.AppController"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
And then I get this error:
Error:
tools:replace specified at line:25 for attribute android:authorities, but no new value specified
The same happens with tools:replace="android.support.v4.content.FileProvider"
.
What am I missing?
To solve this there are two options: either you change your manifest to use a different class than
android.support.v4.content.FileProvider
or you create a PR/issue asking the owner of the lib to change his/hers (that would be the best case scenario).If you want a quick fix, just create a class that extends
FileProvider
such as:and in your manifest file you change it to:
Add to your
AndroidManifest.xml
file:Since you do not change any of the values in the provider, you do not need to include it in your manifest. Just remove those lines.