2

I am trying to update the FileProvider class from android.support.v4.content.FileProvider to androidx.core.content.FileProvider which allows me to build successfully.

When I run ionic cap sync it reverts back to android.support.v4.content.FileProvider...

I have cordova-plugin-androidx-adapter installed.

How can I make it stay as androidx.core.content.FileProvider or make the adapter work?

In my AndroidManifest.xml:

<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"></meta-data>
</provider>
Souleste
  • 1,887
  • 1
  • 12
  • 39
  • 1
    You can try with jetifier: `npm install jetifier --save` `npx jetify` `npx cap sync android` – Misha Mashina Mar 15 '22 at 06:04
  • 3
    @MishaMashina That worked, can you provide an answer so that I can accept it? Also, am I good to remove the `cordova-plugin-androidx-adapter`? – Souleste Mar 15 '22 at 14:42
  • 1
    Thanks for the offer, but no need for an official answer - this issue happens regularly and is already well answered and commented on many questions here :) And you should keep the `cordova-plugin-androidx-adapter` too. – Misha Mashina Mar 15 '22 at 15:45
  • 1
    Does this answer your question? [Migrating a Cordova Android project to AndroidX](https://stackoverflow.com/questions/59429175/migrating-a-cordova-android-project-to-androidx) – cmak Mar 15 '22 at 19:10

1 Answers1

1

The above comment from @MishaMashina is the definitive answer. I am only answering here as I was able to get my project to compile running jetify without using the cordova-plugin-androidx-adapter.

Dan
  • 53
  • 7