pwlin / cordova-plugin-file-opener2

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

Getting android.support.v4.content error after file-opener2 install #251

Closed MiroslavStrycek closed 5 years ago

MiroslavStrycek commented 5 years ago

After cordova plugin add cordova-plugin-file-opener2 getting error: package android.support.v4.content does not exist public class FileProvider extends android.support.v4.content.FileProvider {

path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".opener.provider", file); After plugin was added in project dependencies was added line com.android.support:support-v4:27.+. I tried change the version of support but nothing helps. I am using Cordova 8.1.1, Cordova android platform 7.1.2, Android studio 3.3, Android Gradle Plugin 3.3.0, Gradle: 4.10.1.

shnist commented 5 years ago

hi @MiroslavStrycek, thanks for raising this issue. I will do some investigation with the environment you've described.

shnist commented 5 years ago

can you copy and paste the result of cordova info for me please?

MiroslavStrycek commented 5 years ago

Thx a lot I am stucked with this problem.

shnist commented 5 years ago

hi @MiroslavStrycek, I don't experience the issue when installing and using the dependency on the command line. After some research I think this is an issue with the configuration of your project in Android studio. Try changing the support version to com.android.support:support-v4:27.1.1 in the build.gradle file as per one of the comments in the thread.

MiroslavStrycek commented 5 years ago

Okay I will try it.

shnist commented 5 years ago

@MiroslavStrycek I've also noticed in the config.xml screenshot you've sent that there is a mistake. Can you please remove <variable name="ANDROID_SUPPORT_VERSION" value="27.1.1." /> from your config file. You should only need <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />

MiroslavStrycek commented 5 years ago

Hi I tried what you told me and nothing helps same error. I attach you my configuration if something is wrong. Thanks for help.

cordova android studio
MiroslavStrycek commented 5 years ago

Hi, finally after some research I changed directory from android.support.v4.content.FileProvider to androidx.core.content.FileProvider and solve the problem.

shnist commented 5 years ago

Glad you were able to resolve your issue 👍

timbru31 commented 5 years ago

Sorry to hijack this issue, but the real question is: Are there any plans to migrate to AndroidX? This would be a breaking change and cordova-android is not yet ready itself (see https://github.com/apache/cordova-android/issues/565) but work is ongoing towards this. Just wanted to bring up this question :)

If desired I'm happy to create a new tracking issue for AndroidX compatibility.

shnist commented 5 years ago

hi @timbru31, thanks for brining this to my attention. Please raise another issue and I will pin it. Having looked at that thread you posted and some of the PRs to migrate plugins (e.g. https://github.com/apache/cordova-plugin-camera/pull/418/files) it doesn't look like too much effort, but will require a major bump (also only compatible from Android 9?)