Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constructor FileProvider in class FileProvider cannot be applied to given types #2978

Closed
indapublic opened this issue Jun 2, 2023 · 31 comments

Comments

@indapublic
Copy link

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
@jihokim2
Copy link

jihokim2 commented Jun 2, 2023

Please, Fix this.

@UNIDY2002
Copy link
Contributor

@mganandraj

@rorisme
Copy link

rorisme commented Jun 2, 2023

I have the same issue. Downgrading to 11.26.1 seems to fix it.

@FelipeLimaDeSouza
Copy link

I have the same issue

@efstathiosntonas
Copy link

efstathiosntonas commented Jun 2, 2023

I have the same issue. Downgrading to 11.26.1 seems to fix it.

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.0 the RNCWebViewFileProvider is intentionally left blank, on 12.2.0 is not.

@jiangyuanyuan
Copy link

I have the same issue

@willTerner
Copy link

I have the same issue. Downgrading to 11.26.1 seems to fix it.

no need to go all the way down to 11.x, "react-native-webview": "12.1.0" works fine (notice no ^, ~ before version)

On 12.1.0 the RNCWebViewFileProvider is intentionally left blank, on 12.2.0 is not.

But I can't install 12.2.1. The newest version is 12.2.0.

@efstathiosntonas
Copy link

@willTerner it's 12.1.0 not 12.2.1

@krishna-gujjjar
Copy link

I have the same issue with

"react": "18.2.0",
"react-native": "0.71.8",
"react-native-webview": "^12.2.0"

Error Message

Task :react-native-webview:compileDebugJavaWithJavac FAILED
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

@aspidvip
Copy link

aspidvip commented Jun 2, 2023

I have the same issue with

@mlazari
Copy link

mlazari commented Jun 2, 2023

The issue seems to be that 12.2.0 uses a FileProvider constructor (added in https://cs.android.com/androidx/platform/frameworks/support/+/a4385569db989747caf6b110b345a09ceb86acc7) that is not is not available in older androidx.core:core versions. This is the change - v12.1.0...v12.2.0#diff-8ee52ba9097d8e8909a30c82091de2efd9d4cddc90953b1f320d8a3e8552775cR13. In my case it looks like the project was using androidx.core:core:1.7.0. I forced it to use latest version 1.10.1 by adding this in android/build.gradle and the build issue with react-native-webview 12.2.0 is solved:

allprojects {
  repositories {
    //...
    // Add this:
    configurations.all {
      resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'androidx.core' && requested.name == 'core') {
          details.useVersion '1.10.1'
        }
      }
    }
  }
}

@RohanWeli
Copy link

I have the same issue

@neeteshraj
Copy link

I have the same issue in my react-native application.

@neeteshraj
Copy link

I have the same issue in my react-native application.

Fixed by installing 12.1.0

@mlazari
Copy link

mlazari commented Jun 2, 2023

Yes, there are 2 possible fixes that I know:

  1. Downgrade react-native-webview to 12.1.0
  2. Upgrade androidx.core:core as I shown in my previous message.

@edritech93
Copy link

same issue for me
"react-native-webview": "^12.2.0",

@mganandraj
Copy link
Contributor

Hello everyone .. This is caused by 75e7801 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 #2978 (comment)

Thanks !

@efstathiosntonas
Copy link

@mganandraj can you pin this issue?

@Nensi9
Copy link

Nensi9 commented Jun 5, 2023

getting the same issue.


"react": "18.2.0",
"react-native": "0.71.8",
"react-native-webview": "^12.2.0"

@AbhavThakur
Copy link

AbhavThakur commented Jun 5, 2023

add this in Build.gradle file

allprojects {
  repositories {
    //...
    // Add this:
    configurations.all {
      resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'androidx.core' && requested.name == 'core') {
          details.useVersion '1.10.1'
        }
      }
    }
  }
}

in app/build.gradle file
add this in dependencies

def core_version = "1.10.1"
 implementation "androidx.core:core:$core_version"

@valery-lavrik
Copy link

I 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

@AbhavThakur
Copy link

AbhavThakur commented Jun 8, 2023

I 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

Actually in Build.gradle we are using the latest version ,by default react-native us using old version .So, when we update in future we will not get any error.

@TomCorvus
Copy link

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"

@mganandraj
Copy link
Contributor

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.

@SIDIDEV1
Copy link

SIDIDEV1 commented Jun 9, 2023

Hi,
you just need to change the version of react-native-webview version to 12.1.0 like so

npm uninstall react-native-webview
npm install react-native-webview@12.1.0

After u can do a npx pod-install or cd ios && pod install that's all.

@billnbell
Copy link

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.

OK. yeah unsure when react-native and all modules will support 1.8.0 and up.

@Titozzz
Copy link
Collaborator

Titozzz commented Jun 10, 2023

@mganandraj I'll revert while we find a solution to fix most people issues, keeping this open for follow up

@mganandraj
Copy link
Contributor

@mganandraj I'll revert while we find a solution to fix most people issues, keeping this open for follow up

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.)

@arihirsch
Copy link

Upping this, 12.2.0 doesn't work for me either. Same error as OP

@mlazari
Copy link

mlazari commented Jun 30, 2023

Upping this, 12.2.0 doesn't work for me either. Same error as OP

@arihirsch Update to 12.2.1 or newer (latest is 13.2.2 now), this issue was fixed in 12.2.1

@github-actions
Copy link

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests