2

How to migrate FileProvider to androidx?

In the manifest file, how to specify the FileProvider?

<provider           android:authorities="${applicationId}.FileProvider"              android:name="which.package.to.put.here.FileProvider"
            android:enabled="true"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data android:name="which.package.to.put.here.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_path" />
</provider>

I tried to use androidx.core.content.FileProvider, but I got this error:

java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
uan
  • 857
  • 7
  • 17

1 Answers1

0

This seems to fix the issue:

<provider
            android:authorities="${applicationId}.FileProvider"
            android:name="androidx.core.content.FileProvider"
            android:enabled="true"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_path" />
        </provider>
uan
  • 857
  • 7
  • 17