You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native构建失败:':react-native-gesture-handler:compileDebugKotlin'任务执行出错

React Native Android构建失败:react-native-gesture-handler Kotlin编译错误

错误详情

FAILURE: 构建过程中出现异常导致失败。

  • 问题原因:Execution failed for task ':react-native-gesture-handler:compileDebugKotlin'

执行org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction时失败
编译错误,详情请查看日志

官方排查建议

  • 尝试方案:

    使用--stacktrace选项获取堆栈跟踪信息。
    使用--info或--debug选项获取更多日志输出。
    使用--scan选项获取完整分析信息。

构建失败,耗时3分54秒

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

提示:使用--verbose flag运行CLI以获取更多详情。

解决步骤

该错误源于react-native-gesture-handler库的Kotlin编译过程异常,可尝试以下解决方法:

  1. 检查项目根目录build.gradle文件的dependencies块,确认已安装匹配的Kotlin Gradle Plugin版本。

  2. 清理并重建项目,在项目根目录执行以下命令:

cd android
./gradlew clean
cd ..
react-native run-android
  1. 若问题未解决,更新Kotlin版本:
    在项目根目录build.gradle文件中添加或修改:
ext.kotlin_version = '1.5.21'

同步更新Kotlin Gradle Plugin版本:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
  1. 若以上步骤均无效,尝试排除react-native-gesture-handler库的Kotlin编译依赖:
    在项目根目录build.gradle文件中添加:
configurations.all {
    exclude group: 'com.facebook.react', module: 'react-native-gesture-handler'
}

之后重新执行react-native run-android。


内容的提问来源于stack exchange,提问作者Solomon zefine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 19:05:27