Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating to AndroidX - android.support.FILE_PROVIDER_PATHS location

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?

like image 822
sunlover3 Avatar asked Nov 20 '18 09:11

sunlover3


People also ask

How to migrate an existing Android project to androidx?

With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar. The refactor command makes use of two flags.

Can I migrate to androidx from an older version of support library?

Migrating directly to AndroidX from an older version of the Support Library than 28 isn't recommended. If you use an older version of Support Library such as 26 or 27, it will be easier and smoother to upgrade to Support Library 28 first.

What is the use of Android fileprovider?

Android FileProvider is a sub class of ContentProvider. It is used to share files between different android apps. It is implemented in android v4 Support Library.

How do I create a file provider in Android?

Create FileProvider Steps. Declare FileProvider provider component in AndroidManifest.xml file. Create a share folder xml file to indicate which folder will be shared. 2.1 Define FileProvider In AndroidManifest.xml.


2 Answers

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

like image 57
David Avatar answered Sep 21 '22 16:09

David


<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

like image 40
Roshan S Avatar answered Sep 23 '22 16:09

Roshan S