Migration Cordova to Capacitor - error: package android.support.v4.content does not exist [duplicate]
Asked Answered
S

2

12

I'm trying to migrate my ionic app from cordova to capacitor.

But I'm getting an error in Android build.

android\capacitor-cordova-android-plugins\src\main\java\nl\xservices\plugins\FileProvider.java:4: error: package android.support.v4.content does not exist
public class FileProvider extends android.support.v4.content.FileProvider {

Does anyone knows how to solve this problem?

Slotter answered 9/4, 2020 at 12:23 Comment(2)
see https://mcmap.net/q/747239/-ionic-capacitor-qrscanner-activity-compatGerger
yes @jcesarmobile, I solved he problem with jetifierSlotter
M
42

I was having the same issue, and I fixed it in these foollowing steps:

  1. Go to the FileProvider file where the issue is happening, you can click the path that Android Studio gives you.

  2. Instead of "public class FileProvider extends android.support.v4.content.FileProvider" replace it with "public class FileProvider extends androidx.core.content.FileProvider".

This should fix the issue, hope this helps buddy.

PS. This error does not appear when starting the a project with Capacitor, hopefully they fix these kind of errors with Capacitor 2.0

Maida answered 1/6, 2020 at 15:12 Comment(4)
This is correct. You will need to replace any mention of android.support.v4.content.FileProvider with androidx.core.content.FileProviderSnowdrop
I also had to replace 'android.support.v4.print' with 'androidx.print' and 'android.support.annotation' with 'androidx.annotation'.Topee
In which file do I need to replace it??Pawnshop
android/capacitor-cordova-android-plugins/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileProvider.javaWillson
G
4

try npx cap sync command after adding any plugins. That works for me.

Gigot answered 1/6, 2020 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.