我刚刚开始构建我的第一个React Native应用,但收效甚微。我已经建立了样板代码,但是现在我想为其添加一个单独的屏幕。提示反应导航。
尝试安装模块两次,我运气不太好。我使用了React Navigation本身的Facebook's documentation和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。