使用FileProvider的AndroidManifest合并错误 [英] AndroidManifest merge error using FileProvider

查看:1032
本文介绍了使用FileProvider的AndroidManifest合并错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一个在其AndroidManifest.xml中具有此功能的库:

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>

我的应用程序的AndroidManifest.xml中具有相同的标签:

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

建议在AndroidManifest.xml的元素上添加'tools:replace ="android:authorities"'以覆盖".

Which suggests to "add 'tools:replace="android:authorities"' to element at AndroidManifest.xml to override".

因此,我在应用程序的AndroidManifest.xml中这样添加tools:replace="android:authorities":

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

然后我得到这个错误:

Error:
tools:replace specified at line:25 for attribute android:authorities, but no new value specified

tools:replace="android.support.v4.content.FileProvider"也是如此.

我想念什么?

推荐答案

要解决此问题,有两种选择:要么更改清单以使用与android.support.v4.content.FileProvider不同的类,要么创建一个PR/issue询问其所有者.更改他/她的库(这是最好的情况).

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

如果要快速修复,只需创建一个扩展FileProvider的类,例如:

If you want a quick fix, just create a class that extends FileProvider such as:

import android.support.v4.content.FileProvider;

public class MyFileProvider extends FileProvider {
}

,然后在清单文件中将其更改为:

and in your manifest file you change it to:

<provider android:name=".MyFileProvider" ... >

这篇关于使用FileProvider的AndroidManifest合并错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆