admin管理员组文章数量:1335813
My colleague upgraded gradle 8.0 to 8.10 so that react-native 0.73.9 could work on Android, targetting API 34. It's working on his computer, but not on mine. I'm still having the same error, with unresoved reference 'serviceOf' :
> Configure project :gradle-plugin
The .gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: .10/userguide/upgrading_version_8.html#deprecated_access_to_conventions
e: file:///C:/Users/achil/Desktop/Hopteo/Code/HopteoRNcli/node_modules/@react-native/gradle-plugin/build.gradle.kts:10:49: Unresolved reference: serviceOf
e: file:///C:/Users/achil/Desktop/Hopteo/Code/HopteoRNcli/node_modules/@react-native/gradle-plugin/build.gradle.kts:54:11: Unresolved reference: serviceOf
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\achil\Desktop\Hopteo\Code\HopteoRNcli\node_modules\@react-native\gradle-plugin\build.gradle.kts' line: 10
* What went wrong:
Script compilation errors:
Line 10: import .gradle.configurationcache.extensions.serviceOf
^ Unresolved reference: serviceOf
Line 54: serviceOf<ModuleRegistry>()
^ Unresolved reference: serviceOf
2 errors
some lines from package.json :
"dependencies": {
"react": "18.2.0",
"react-native": "^0.73.9",
}
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/react": "^18.0.24",
"@types/react-native-vector-icons": "^6.4.14",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.76.8",
"react-native-rename": "^3.2.13",
"react-test-renderer": "18.2.0",
"typescript": "^4.8.4"
},
"engines": {
"node": ">=16"
}
android/build.gradle file
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.4.0")
classpath("com.facebook.react:react-native-gradle-plugin:0.75.3")
// add plug-in google-services to handle google-services.json and handle dependencies :
classpath("com.google.gms:google-services:4.4.0") // added for firebase
classpath(".jetbrains.kotlin:kotlin-gradle-plugin")
}
}
apply plugin: "com.facebook.react.rootproject"
line from gradle-wrapper.properties
distributionUrl=https\://services.gradle/distributions/gradle-8.10-all.zip
I tried this :
- npm install, and then npm start, press a ===> I have exactly the same error
- deleting node_modules, npm install, npm start, press a ===> same error
- npx react-native doctor ===> everything seems to be set up correctly
- npm start --reset-cache ===> same error
- ./gradlew clean ===> same error
- ./gradlew clean --warning-mode all ===> same error, nothing more
Just in case I upgraded my android studio (cause my colleague is on Koala version) :
- installing android studio Koala, setting up environnement variable and everything => same error when building
- installing android studio ladybug, ... => same error
I don't understand why I still have the same error, and why it's working for my colleague
My colleague upgraded gradle 8.0 to 8.10 so that react-native 0.73.9 could work on Android, targetting API 34. It's working on his computer, but not on mine. I'm still having the same error, with unresoved reference 'serviceOf' :
> Configure project :gradle-plugin
The .gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle./8.10/userguide/upgrading_version_8.html#deprecated_access_to_conventions
e: file:///C:/Users/achil/Desktop/Hopteo/Code/HopteoRNcli/node_modules/@react-native/gradle-plugin/build.gradle.kts:10:49: Unresolved reference: serviceOf
e: file:///C:/Users/achil/Desktop/Hopteo/Code/HopteoRNcli/node_modules/@react-native/gradle-plugin/build.gradle.kts:54:11: Unresolved reference: serviceOf
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\achil\Desktop\Hopteo\Code\HopteoRNcli\node_modules\@react-native\gradle-plugin\build.gradle.kts' line: 10
* What went wrong:
Script compilation errors:
Line 10: import .gradle.configurationcache.extensions.serviceOf
^ Unresolved reference: serviceOf
Line 54: serviceOf<ModuleRegistry>()
^ Unresolved reference: serviceOf
2 errors
some lines from package.json :
"dependencies": {
"react": "18.2.0",
"react-native": "^0.73.9",
}
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/react": "^18.0.24",
"@types/react-native-vector-icons": "^6.4.14",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.76.8",
"react-native-rename": "^3.2.13",
"react-test-renderer": "18.2.0",
"typescript": "^4.8.4"
},
"engines": {
"node": ">=16"
}
android/build.gradle file
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.4.0")
classpath("com.facebook.react:react-native-gradle-plugin:0.75.3")
// add plug-in google-services to handle google-services.json and handle dependencies :
classpath("com.google.gms:google-services:4.4.0") // added for firebase
classpath(".jetbrains.kotlin:kotlin-gradle-plugin")
}
}
apply plugin: "com.facebook.react.rootproject"
line from gradle-wrapper.properties
distributionUrl=https\://services.gradle./distributions/gradle-8.10-all.zip
I tried this :
- npm install, and then npm start, press a ===> I have exactly the same error
- deleting node_modules, npm install, npm start, press a ===> same error
- npx react-native doctor ===> everything seems to be set up correctly
- npm start --reset-cache ===> same error
- ./gradlew clean ===> same error
- ./gradlew clean --warning-mode all ===> same error, nothing more
Just in case I upgraded my android studio (cause my colleague is on Koala version) :
- installing android studio Koala, setting up environnement variable and everything => same error when building
- installing android studio ladybug, ... => same error
I don't understand why I still have the same error, and why it's working for my colleague
Share Improve this question asked Nov 19, 2024 at 20:30 BOUTILLIER AchilleBOUTILLIER Achille 611 silver badge2 bronze badges2 Answers
Reset to default 8The whole serviceOf is no longer necessary; it has already been removed from the main branch. You can follow this PR to create a patch-package and fix the issue:
- Edit file node_modules/react-native-gradle-plugin/build.gradle.kts as shown in the PR
- Run npx patch-package react-native-gradle-plugin.
Try:
rm -rf node_modules package-lock.json
npm audit fix --forced
npm install
npm dedupe
It worked for some people on github, but not for me. Ig happened after i upgraded to expo 52.
本文标签:
版权声明:本文标题:react native 0.73.9 build fails with unresolved reference 'serviceOf' in @react-nativegradle-pluginbuild.gradle. 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742400251a2467743.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论