pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 583 forks source link

android.support.v4.content.FileProvider not found #326

Closed wallstudios closed 1 year ago

wallstudios commented 2 years ago

Was having an issue building for Android on ionic

android.support.v4.content.FileProvider not found

Ionic:

Ionic CLI : 6.18.0 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 5.0.5 @angular-devkit/build-angular : 0.900.6 @angular-devkit/schematics : 9.0.6 @angular/cli : 9.0.6 @ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 10.0.0 Cordova Platforms : android 10.1.1, ios 6.2.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 19 other plugins)

Utility:

cordova-res : 0.15.3 native-run : 1.5.0

System:

ios-deploy : 1.11.4 ios-sim : 8.0.2 NodeJS : v16.10.0 (/usr/local/Cellar/node/16.10.0/bin/node) npm : 7.24.0 OS : macOS Big Sur Xcode : Xcode 13.1 Build version 13A1030d

making below change to the FileProvider.java fixes the problem.

Not sure if it is my specific setup or not.

// public class FileProvider extends android.support.v4.content.FileProvider { // }

public class FileProvider extends androidx.core.content.FileProvider { }

michelkuehn commented 2 years ago

If you want to make it work with cordova-android 10+, you will have to add this plugin : cordova-plugin-androidx-adapter

Source : https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html

wallstudios commented 2 years ago

Thanks. I already had that plugin installed. Might have been a config issue at my end.

martinko94 commented 2 years ago

Hi, I have the same problem, did you manage to make it work?

wallstudios commented 2 years ago

Do you have the androidX plugin installed?

if so and still the same error try changing the line in the FileProvider.java file in the plugin directory. Do a search in your files for "android.support.v4.content.FileProvider " then change as per above.

worked for me.

sahilrajthapa commented 2 years ago

Hi @martinko94 installing jetifier will work. Have look at this

npm install jetifier
npx jetify
jammind commented 1 year ago

In FileProvider.java, simply replace android.support.v4.content.FileProvider with androidx.core.content.FileProvider and it works for me.

Cordova android 10.1.2 Target SDK version 31

shnist commented 1 year ago

this should now be fixed in the latest version