且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android应用程序中添加多个文件提供程序

更新时间:2023-12-06 10:41:16

我在此链接上找到了解决方案 可以在FileProvider中使用多个权限吗?

Guys I found solution on this link Possible to use multiple authorities with FileProvider?

基本上的问题是我的库和应用程序具有相同的名称android.support.v4.content.FileProvider,因此它在清单合并中发生冲突,为避免这种情况,我需要删除扩展文件提供程序的空类并使用它的提供程序名称

Basically problem is my library and application have same name android.support.v4.content.FileProvider so it colliding in manifest merger, to avoid this I need to defile empty class extending File provider and use it provider name

<provider
            android:name="com.MAG.MAGFileProvider"
            android:authorities="${applicationId}.provider;"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

并声明这样的类

import android.support.v4.content.FileProvider;
public class MAGFileProvider extends FileProvider
{
    //we extend fileprovider to stop collision with chatbot library file provider
    //this class is empty and used in manifest
}