安装 React Navigation 后无法构建或安装 React Native 应用程序

Can't build or install React Native app after installing React Navigation

我刚刚开始构建我的第一个 React Native 应用程序,但收效甚微。我已经构建了样板代码,但现在我想为其添加一个单独的屏幕。提示反应导航。

我已经尝试安装该模块两次,但运气不佳。我自己使用了 React Navigation 的 Facebook's documentation and the Getting Started 指南。仍然没有运气。

我得到的错误与我的 android 文件夹中的 build.gradle 文件有关。根据入门指南,我确实在我的依赖项区域中添加了两行,但这似乎没有任何效果。

报错信息如下:

Could not compile build file: 
'C:\Users\USERNAME\Documents\ReactNative\WasteAway\android\app\build.gradle\'
> startup failed
General error during semantic analysis: Unsupported class file major version 57

我在build.gradle文件中的依赖如下:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

我是否遗漏了一些明显的东西,或者我是否跳过了教程中的某个步骤?伙计们,我看不出哪里错了。非常感谢任何帮助。

回答这个问题是因为有人建议我解决这个问题: 看起来是我使用的 JDK 版本导致了问题。奇怪的是,我使用的是一个臭名昭著的错误版本太新了。卸载并还原 JDK1.8 解决了我的问题。说明 here.