gradle 任务:React Native防火墙:编译发布JavaWithJavac失败

kzmpq1sx  于 2023-01-09  发布在  React
关注(0)|答案(6)|浏览(271)

我克隆了我自己的repo. project in on react native,我安装了节点模块并根据我的项目要求设置了Jdk8。然后我使用react native run-android运行我的项目。
任务:React Native防火墙:编译发布JavaWithJavac失败
失败:生成失败,出现异常。

* 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)

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

kt06eoxx

kt06eoxx1#

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

npx jetify

从项目根目录。

r6hnlfcb

r6hnlfcb2#

这是react native 0.60+的一个非常荒谬的问题,因为它希望安装jetier。
所以我解决了它首先安装jetifier,你可以使用Yarn或npm。

yarn add jetifier

npm jetifier

然后应该执行npx jetify

1bqhqjot

1bqhqjot3#

可能是一个迟来的答案,但我今天遇到了同样的错误,这就是我如何解决它
在运行./gradlew assembleRelease之前,您需要运行npx jetify
上述命令将android.support.v4.app.* package转换为androidx.core.app.*,这有助于编译构建。

3htmauhk

3htmauhk4#

正如react native 0.60+的其他答案所述,您应该安装jetifier

npm jetifier

我在package.json中将其设置为postinstall脚本,因此每次npm安装完成时都会这样做。

"postinstall": "npx jetify"

此外,在您的应用/build.gradle中,请确保您已

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

dependencies {
    ...

    if (enableHermes) {
        // for RN 0.60.x
        def hermesPath = "../../node_modules/hermesvm/android/"

        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}
7rtdyuoh

7rtdyuoh5#

您可以按如下方式解决此问题:
1.安装Jetifier:
Yarn添加装置
1.通过以下命令启动Jetifier:
纱道喷射

  • 开始了 *
vi4fp9gy

vi4fp9gy6#

请尝试将JDK更新为JDK 11,然后尝试编译
使用SDKMAN管理同一台计算机上的不同Java版本。

相关问题