Apple M1 芯片上的 React Native run-android 抛出错误,“无法打开脚本的 dsl 通用类缓存”

Wai*_*ein 6 react-native

我正在使用 React-Native 构建移动应用程序。我现在尝试在 Android 模拟器上运行我的应用程序。首先,这是这个问题的延续。我按照上一个问题中提到的安装了Android Studio并配置了环境。

这就是我为修复上一个问题中的错误所做的。

我将 android/gradle.properties 中的第 13 行更改为:

org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Run Code Online (Sandbox Code Playgroud)

这次当我运行“react-native run-android”命令时,出现错误。该错误表示找不到 '/Users/waihein/Desktop/Code/shar-kya-mal-app/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' 文件。

所以我运行npm i @react-native-community/cli-platform-android命令来安装所需的包。

我删除了node_modules文件夹并再次运行“npm install”。然后我运行“react-native run-android”。这次我收到以下错误。

* Where:
Settings file '/Users/waihein/Desktop/Code/shar-kya-mal-app/android/settings.gradle' line: 8

* What went wrong:
A problem occurred evaluating settings 'sharkyamalapp'.
> Could not open dsl generic class cache for script '/Users/waihein/Desktop/Code/shar-kya-mal-app/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (/Users/waihein/.gradle/caches/6.8/scripts/a43tr593rdpk11ispliu0nu14).
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
Run Code Online (Sandbox Code Playgroud)

但该文件就在那里,我可以在 node_modules 文件夹中看到它。我该如何修复它?