Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 719
dritan Avatar asked Apr 09 '20 12:04

dritan


2 Answers

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

like image 62
Maxrngl Avatar answered Nov 20 '22 12:11

Maxrngl


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

like image 4
pl-jay Avatar answered Nov 20 '22 12:11

pl-jay