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

Could not find matching constructor for: java.io.File(File) #33641

Closed
rafaelmaeuer opened this issue Apr 14, 2022 · 2 comments
Closed

Could not find matching constructor for: java.io.File(File) #33641

rafaelmaeuer opened this issue Apr 14, 2022 · 2 comments

Comments

@rafaelmaeuer
Copy link

Description

When upgrading to RN 0.68.0 I moved from gradle-wrapper 6.9.1 to 7.3.3 and gradle 4.2.2 to 7.1.1 resulting in following error on gradle-sync: Could not find matching constructor for: java.io.File(File).

With help of: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.io.File(File) I added toString() in L41 of /node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle and gradle sync is working again.

The patch-package diff is attached, I can create a PR if requested.

Version

0.68.0

Output of npx react-native info

System:
OS: macOS 12.3.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.13 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.7.2 - /usr/local/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 8.5.2 - /usr/local/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 26, 28, 29, 30, 31
Build Tools: 27.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0, 31.0.0, 31.0.0, 32.0.0, 33.0.0
System Images: android-28 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8309675
Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
Languages:
Java: 11.0.12 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.0.0 => 18.0.0
react-native: 0.68.0 => 0.68.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Could not find a way to reproduce the issue with the Template-Project yet...

Snack, code example, screenshot, or link to a repository

diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index d876b13..88be08c 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -38,7 +38,7 @@ def hermesCommand = config.hermesCommand ?: "../../node_modules/hermes-engine/%O
 def detectCliPath(config, reactRoot) {
     // 1. preconfigured path
     if (config.cliPath) {
-        def cliJsAbsolute = new File(config.cliPath)
+        def cliJsAbsolute = new File(config.cliPath.toString())
         if (cliJsAbsolute.exists()) {
             return cliJsAbsolute.getAbsolutePath()
         }
@rafaelmaeuer
Copy link
Author

The problem was coming from the migration of uni-modules to expo-modules when using file references like this (from https://github.com/expo/fyi/blob/main/expo-modules-migration.md#android):

new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")

I was able to solve the issue by moving from the above example code to relative references like:

apply from: "../../node_modules/react-native/react.gradle".

@onedanshow
Copy link

Thanks @rafaelmaeuer!

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

No branches or pull requests

3 participants