React Native实时数据库构建错误



所以我尝试将firebase数据库添加到现有项目中,但它一直在抛出这个渐变错误,然而,当我创建一个新项目并安装它时,它运行得很好,甚至我目前正在进行的项目也是几个月前才创建的,所以它不是一个老项目,

这些是我的依赖项:

"@react-native-community/masked-view": "^0.1.11",
"@react-native-firebase/app": "^14.5.1",
"@react-native-firebase/database": "^14.5.1",
"@react-navigation/bottom-tabs": "^6.1.0",
"@react-navigation/native": "^6.0.7",
"@react-navigation/native-stack": "^6.3.0",
"@react-navigation/stack": "^6.1.0",
"firebase": "^9.6.9",
"intl": "^1.2.5",
"react": "17.0.2",
"react-moment": "^1.1.1",
"react-native": "0.67.3",

这些是我在控制台中得到的日志

> Configure project :react-native-firebase_database
Subproject ':react-native-firebase_database' has location '--node_modules@react-native-firebasedatabaseandroid' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: https://docs.gradle.org/7.2/userguide/upgrading_version_7.html#deprecated_flat_project_structure

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-firebase_database'.
> Could not load compiled classes for build file '--node_modules@react-native-firebasedatabaseandroidbuild.gradle' from cache.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 12s
at makeError (--node_modules@react-native-communitycli-platform-androidnode_modulesexecaindex.js:174:9)
at --node_modules@react-native-communitycli-platform-androidnode_modulesexecaindex.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (--node_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:109:5)
at async Command.handleAction (--node_modules@react-native-communityclibuildindex.js:192:9)

你好吗?

尝试将这些行包括在android/settings.gradle.中

include ':@react-native-firebase_app'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/app/android')

您也可以将compileSdkVersion设置为30或31。以及targetSdkVersion 30或更高版本。

干杯

所以基本上删除gradle缓存为我解决了这个问题,但是gradlew-clean也不起作用,所以我不得不删除缓存文件夹

  • 在窗口上:%USERPROFILE%.gradlecaches
  • 在Mac/UNIX:~/.gradle/caches/

如何清除渐变缓存?

最新更新