android.support.v4.content.FileProvider not found

后端 未结 8 1288
终归单人心
终归单人心 2021-02-01 13:37

I am trying to upgrade a working old app to support Android API 26, and one of the thing I need to use is android.support.v4.content.FileProvider - but it was not found.

相关标签:
8条回答
  • 2021-02-01 14:09

    As of AndroidX (the repackaged Android Support Library), the path is androidx.core.content.FileProvider so the updated provider tag would be:

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>
    

    Android Support Libraries are now in the androidx.* package hierarchy.

    android.* is now reserved to the built-in Android System Libraries.

    0 讨论(0)
  • 2021-02-01 14:11

    Create your class

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

    Add this provider into your AndroidManifest.xml under application tag:

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