运行 npm start (react native) 时出现错误(react-native-gradle-plugin:compileKotlin FAILED)

when running a npm start (react native) i get an error (react-native-gradle-plugin:compileKotlin FAILED)

提问人:username444 提问时间:7/9/2023 更新时间:7/9/2023 访问量:103

问:

PS C:\Users\akram\Desktop\mobileApp> npx react-native run-android info JS 服务器已在运行。 info 正在安装应用程序...

任务 :react-native-gradle-plugin:compileKotlin 失败 1 个可操作任务:1 个已执行 e: C:\Users\akram\Desktop\mobileApp\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\tasks\BundleHermesCTask.kt: (138, 11): 此声明是实验性的,其用法必须标有“@kotlin”。ExperimentalStdlibApi' 或 '@OptIn(kotlin.ExperimentalStdlibApi::class)'

失败:生成失败,出现异常。

  • 出了什么问题: 任务“:react-native-gradle-plugin:compileKotlin”执行失败。

编译错误。有关更多详细信息,请参阅日志

  • 尝试:

使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整的见解。

构建在 10 秒内失败

错误:无法安装应用程序。确保您已设置 Android 开发环境:https://reactnative.dev/docs/environment-setup。 错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 e: C:\Users\akram\Desktop\mobileApp\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\tasks\BundleHermesCTask.kt: (138, 11): 此声明是实验性的,其用法必须标有“@kotlin”。ExperimentalStdlibApi' 或 '@OptIn(kotlin.ExperimentalStdlibApi::class)'

失败:生成失败,出现异常。

  • 出了什么问题: 任务“:react-native-gradle-plugin:compileKotlin”执行失败。

编译错误。有关更多详细信息,请参阅日志

  • 尝试:

使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整的见解。

构建在 10 秒内失败

at makeError (C:\Users\akram\Desktop\mobileApp\node_modules\execa\index.js:174:9)
at C:\Users\akram\Desktop\mobileApp\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Users\akram\Desktop\mobileApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:82:7)
at async Command.handleAction (C:\Users\akram\Desktop\mobileApp\node_modules\@react-native-community\cli\build\index.js:108:9)

info 运行带有 --verbose 标志的 CLI 以获取更多详细信息。

我尝试删除节点模块并重新安装,但出现相同的错误

java react-native android-gradle-plugin gradle-kotlin-dsl

评论

0赞 saqib 7/9/2023
似乎是 stackoverflow.com/questions/76593725/ 的复制品...... 希望这有帮助

答: 暂无答案