首页 > 解决方案 > React Native Mac M1 Android Emulator:构建失败并出现异常

问题描述

我检查了类似的问题,但似乎无法找到匹配项。据我所知,我也遵循了所有可用的设置指南。

我正在尝试使用带有 Android Emulator 的 react-native CLI 在 MacBook Air M1 上创建一个 React Native 应用程序。当我尝试使用 npx react-native run-android 运行构建时,我遇到了构建失败,我真的不明白。

我正在从 Android Studio Arctic Fox 运行模拟器,使用 API 31 Android 12 Preview 'S' arm64 的 Pixel 5(显然必须运行 arm64 图像才能在 M1 上工作?)

我在下面附上了构建失败,但我不得不连接,因为它超过了 30k 个字符的限制。任何人都可以帮忙吗?提前致谢...


FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/android/settings.gradle'

* What went wrong:
Could not compile settings file '/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/android/settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 60

  java.lang.IllegalArgumentException: Unsupported class file major version 60
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177)
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163)
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:284)
    ...

  1 error


* 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 1s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/android/settings.gradle'

* What went wrong:
Could not compile settings file '/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/android/settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 60

  java.lang.IllegalArgumentException: Unsupported class file major version 60
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177)
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163)
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:284)
    ...

  1 error


* 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 1s

    at makeError (/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
    at /Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/Users/marccooling/WebstormProjects/RN_YTCourse/tut8_flexbox/node_modules/@react-native-community/cli/build/index.js:186:9)

标签: react-nativeandroid-emulatorreact-native-androidapple-m1react-native-cli

解决方案


推荐阅读