我正在尝试在我的expo React Native应用程序中更新gradle,为此我在android级别执行了“./gradlewwrapper --gradle-version 8.9”。但是当我看到更新日志时,出现这个错误:
> Configure project :gradle-plugin
e: file:///home/enzo/Desktop/Projetos/React-Native/BarON/node_modules/@react-native/gradle-plugin/build.gradle.kts:10:49: Unresolved reference: serviceOf
e: file:///home/enzo/Desktop/Projetos/React-Native/BarON/node_modules/@react-native/gradle-plugin/build.gradle.kts:54:11: Unresolved reference: serviceOf
FAILURE: Build failed with an exception.
* Where:
Build file '/home/enzo/Desktop/Projetos/React-Native/BarON/node_modules/@react-native/gradle-plugin/build.gradle.kts' line: 10
* What went wrong:
Script compilation errors:
Line 10: import org.gradle.configurationcache.extensions.serviceOf
^ Unresolved reference: serviceOf
Line 54: serviceOf<ModuleRegistry>()
^ Unresolved reference: serviceOf
2 errors
我尝试编辑
build.gradle
文件中依赖项的类路径和 gradle-wrapper.properties
文件中的 distributionUrl,但错误仍然存在。我还尝试更新 React Native 插件 (npm update react-native
) 和 expo(npm update expo
),它已经是最新的了。我无法使用任何 gradle 命令,因为如果我这样做会返回相同的错误。
这里有一些有用的信息:
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
应用程序级别的build.gradle
dependencies {
classpath('com.android.tools.build:gradle:8.5')
classpath('com.facebook.react:react-native-gradle-
}
只需将 gradle-8.9-all 降级为 gradle-8.8-all