任务 :react-native-firebase:compileReleaseJavaWithJavac 失败

May*_*pta 2 android gradle build.gradle react-native firebase-realtime-database

我克隆了我自己的仓库。在 react native 项目中,我安装了节点模块并根据我的项目要求设置了 Jdk8。然后我使用 react-native run-android 运行我的项目。显示错误

任务 :react-native-firebase:compileReleaseJavaWithJavac 失败

FAILURE:构建失败,出现异常。

* What went wrong:
Execution failed for task ':react-native-firebase:compileReleaseJavaWithJavac'.
> Could not create service of type GeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

* 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 3s
13 actionable tasks: 2 executed, 11 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug
    at checkExecSyncError (child_process.js:601:13)
    at Object.execFileSync (child_process.js:621:13)
    at runOnAllDevices (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
    at buildAndRun (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
    at isPackagerRunning.then.result (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
Run Code Online (Sandbox Code Playgroud)

我的 react-native、react-native-cli、react-native-firebase 版本的所有软件包都与所需的项目相同。

小智 6

如果您使用的是 React-Native 0.60+,请确保使用。

npx喷气机

从项目根目录。


Gau*_*Roy 5

对于 React Native 0.60+ 来说,这是一个非常荒谬的问题,因为它想要安装 jetifier。

所以我通过首先安装jetifier解决了这个问题,你可以使用yarn或npm。

yarn add jetifier 
Run Code Online (Sandbox Code Playgroud)

或者

npm jetifier 
Run Code Online (Sandbox Code Playgroud)

然后你应该执行npx jetify