33

I am in the middle of migrating a project to AndroidX and I am blocked with an issue.

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

I searched all the Internet and couldn't find a solution for this: what should I add instead of android.support.FILE_PROVIDER_PATHS for AndroidX?

sunlover3
  • 1,999
  • 1
  • 20
  • 25
  • 3
    It looks to be still the same – https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/core/src/main/java/androidx/core/content/FileProvider.java#343. What problems are you having? – Mike M. Nov 20 '18 at 09:40
  • 4
    You are right. I had no issue, but I wanted to be sure that this won't crash at some point and because I saw the "support" keyword there, I thought that Android Studio didn't do the migration right (for example, for the android.support.design.widget.BottomNavigationView it didn't work. I had to do it manually.) Thanks for the answer! – sunlover3 Nov 20 '18 at 09:49
  • could you please show the method where you are fetching the image. – Ashish Oct 07 '19 at 06:07
  • 1
    Up to now, the `FileProvider` class from `AndroidX` package has a final static string variable called `META_DATA_FILE_PROVIDER_PATHS` which references the old string used on the support library: `"android.support.FILE_PROVIDER_PATHS"`. Therefore I guess it's ok to use it the xml file. – Leonardo Sibela Oct 24 '19 at 13:55
  • In android manifest it is already like that (androidx.core.content.FileProvider), but in fileprovider.java file it is different android.support.v4.content.FileProvider => Always I need to change this manually to take a android build – Manoj Manu M May 26 '21 at 06:46

2 Answers2

49

Still the same. android.support.FILE_PROVIDER_PATHS is in the example here

David
  • 2,129
  • 25
  • 34
16
<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="com.mydomain.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

For androidx, the metadata should be like this. Checkout this from android studio : https://developer.android.com/reference/androidx/core/content/FileProvider.html

Roshan S
  • 667
  • 6
  • 10