AndroidManifest merge error using FileProvider

后端 未结 4 715
忘掉有多难
忘掉有多难 2020-12-29 07:02

I\'m trying to use a library that has this in its AndroidManifest.xml:

    

        
相关标签:
4条回答
  • 2020-12-29 07:22

    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:

    import android.support.v4.content.FileProvider;
    
    public class MyFileProvider extends FileProvider {
    }
    

    and in your manifest file you change it to:

    <provider android:name=".MyFileProvider" ... >
    
    0 讨论(0)
  • 2020-12-29 07:22

    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.

    0 讨论(0)
  • 2020-12-29 07:24

    For those using sdk 28 and up, if you are migrating to androidx, solution is :

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true"
        tools:replace="android:authorities">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths"/>
    </provider>
    
    0 讨论(0)
  • 2020-12-29 07:36

    Add to your AndroidManifest.xml file, inside the application tag:

        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"
                tools:replace="android:resource" />
        </provider>
    
    0 讨论(0)
提交回复
热议问题