react-native-webview: constructor FileProvider in class FileProvider cannot be applied to given types
Repository here
Versions
react-native: 0.71.8
react-native-webview: 12.2.0
Steps are:
npx react-native@latest init reactnativewebviewissue
npm run android // All is fine
npm install --save react-native-webview
npm run android // Fault
Error message:
> Task :react-native-webview:compileDebugJavaWithJavac FAILED
37 actionable tasks: 24 executed, 13 up-to-date
/Volumes/Data/Workspace/github/reactnativewebviewissue/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java:13: error: constructor FileProvider in class FileProvider cannot be applied to given types;
super(R.xml.file_provider_paths);
^
required: no arguments
found: int
reason: actual and formal argument lists differ in length
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 19
- Comments: 31 (4 by maintainers)
Commits related to this issue
- fix pnpm installation on mac os — committed to authier-pm/authier by capaj a year ago
- downgrade react-native-webview to fix android build https://github.com/react-native-webview/react-native-webview/issues/2978#issuecomment-1573596888 — committed to aroucha-miguel/my-reddit-client by aroucha-miguel a year ago
no need to go all the way down to
11.x,"react-native-webview": "12.1.0"works fine (notice that there’s no^,~before version)On
12.1.0theRNCWebViewFileProvideris intentionally left blank, on12.2.0is not.I’m looking into making the usage of the new construction conditional on the availability of the new version of android modules … Please hold on.
The issue seems to be that 12.2.0 uses a
FileProviderconstructor (added in https://cs.android.com/androidx/platform/frameworks/support/+/a4385569db989747caf6b110b345a09ceb86acc7) that is not is not available in olderandroidx.core:coreversions. This is the change - https://github.com/react-native-webview/react-native-webview/compare/v12.1.0...v12.2.0#diff-8ee52ba9097d8e8909a30c82091de2efd9d4cddc90953b1f320d8a3e8552775cR13. In my case it looks like the project was usingandroidx.core:core:1.7.0. I forced it to use latest version1.10.1by adding this inandroid/build.gradleand the build issue withreact-native-webview12.2.0 is solved:I have the same issue. Downgrading to
11.26.1seems to fix it.Hi there, Solution above is working but not really safe. Forcing AndroidX Core to 1.10.1 can cause errors on other dependencies during build. Downgrade to 12.1.0 version is the best solution until the problem is solved or instruction is given.
Use the tilde on your dependency version range to avoid getting next minor version like
"react-native-webview": "~12.1.0"Fixed by installing 12.1.0
@willTerner it’s
12.1.0not12.2.1I don’t want to change build.gradle files because in the future, when you have to update react-native, there will be problems with editing these files. I think it would be more correct to roll back to version 12.1.0 for now and wait for a fix from the developer
getting the same issue.
Hello everyone … This is caused by https://github.com/react-native-webview/react-native-webview/commit/75e7801a6255b37f6887d29d10b9ba688e051416 which I merged a couple of days ago to mitigate large number of crashes reported in some OEM devices.
The motivation behind the fix was to leverage the change https://android-review.googlesource.com/c/platform/frameworks/support/+/1978527 which added a workaround to the androidx.core module to avoid stripping the File provider metadata.
The fix to androidx.core is available from https://developer.android.com/jetpack/androidx/releases/core#core-1.8.0-alpha06 (which was released more than an year ago) onwards. Could you folks upgrade to this version to avoid the crash ? Transitive dependency can be explicitly resolved as @mlazari suggested above https://github.com/react-native-webview/react-native-webview/issues/2978#issuecomment-1573469986
Thanks !
I have the same issue
Hi @Titozzz Sure, please go ahead with the revert.
I will continue investigating on getting this change back in a way that works with all versions of androidx libraries. We should also try to get react native to transitive depend on newer androidx versions.
For short term, I can add a local patch.
(By the way, Sorry for introducing this situation. I didn’t realize that so many codebases are still referring to the old version of androidx.core library.)
@mganandraj I’ll revert while we find a solution to fix most people issues, keeping this open for follow up
Hi, you just need to change the version of react-native-webview version to 12.1.0 like so
After u can do a
npx pod-installorcd ios && pod installthat’s all.add this in Build.gradle file
in app/build.gradle file add this in dependencies
Yes, there are 2 possible fixes that I know:
react-native-webviewto 12.1.0androidx.core:coreas I shown in my previous message.I have the same issue with
Error Message