我正在开发一个带有 React Native (/expo) 的简单应用程序。当我执行以下 4 个命令(按 Windows 11、Expo 51 上的顺序)这样简单的操作时:
npx create-expo-app Test --template
(选择 Blank
模板;没有 Typescript)cd Test
npm install
npx expo run:android
我得到以下输出和错误:
📝 Android package Learn more: https://expo.fyi/android-package
√ What would you like your Android package name to be? ... com.pmaddineedi.Test
√ Created native directory
√ Updated package.json
» android: userInterfaceStyle: Install expo-system-ui in your project to enable this feature.
√ Finished prebuild
› Building app...
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\pmadd\Mobile Development\Audacity\Test\android\settings.gradle' (C:\Users\pmadd\.gradle\caches\8.6\scripts\9jvl7af6mie02hkplgyjc1nfd).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66
* 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 758ms
Error: C:\Users\pmadd\Mobile Development\Audacity\Test\android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1
Error: C:\Users\pmadd\Mobile Development\Audacity\Test\android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1
at ChildProcess.completionListener (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\spawn-async\build\spawnAsync.js:42:23)
at Object.onceWrapper (node:events:634:26)
at ChildProcess.emit (node:events:519:28)
at cp.emit (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5)
...
at spawnAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\spawn-async\build\spawnAsync.js:7:23)
at spawnGradleAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\cli\build\src\start\platforms\android\gradle.js:96:48)
at assembleAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\cli\build\src\start\platforms\android\gradle.js:74:18)
at runAndroidAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\cli\build\src\run\android\runAndroidAsync.js:45:37)
但是,
npm start
效果非常好。
我该如何解决这个问题?
请注意,我在网上看到了许多解决此问题的解决方案,但我看到的似乎都不起作用。
我正在使用java jdk 20,因为看起来我需要17+,而22太新了
使用
gradle init
并输入以下内容即可:
项目类型:申请(2)
实现语言:Kotlin(4)
生成多个子项目进行应用:否
构建脚本 DSL:Kotlin(1)
目标 Java 版本:20
使用新的 API 和行为生成构建:是