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

React Native安卓构建失败:无法创建compileDebugKotlin任务

问题

我们有一个React Native应用,在朋友的电脑上运行完全正常,但在我的计算机上仅iOS端可正常运行。尝试构建安卓端时出现如下报错:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':tasks'.
> Could not create task ':lottie-react-native:compileDebugAndroidTestKotlin'.
   > No enum constant org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.JvmTargetValidationMode.WARNİNG

* 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

BUİLD FAILED in 13s

在Android Studio中运行该应用,出现类似错误:

Multiple build operations failed.
    Could not create task ':lottie-react-native:compileDebugKotlin'.
    Could not create task ':react-native-avoid-softinput:compileDebugKotlin'.
    Could not create task ':react-native-gesture-handler:compileDebugKotlin'.
    Could not create task ':react-native-pager-view:compileDebugKotlin'.
    Could not create task ':react-native-safe-area-context:compileDebugKotlin'.
    Could not create task ':react-native-screens:compileDebugKotlin'.
    Could not create task ':react-native-webview:compileDebugKotlin'.
Could not create task ':lottie-react-native:compileDebugKotlin'.
No enum constant org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.JvmTargetValidationMode.WARNİNG

解决方案

  • 检查系统区域设置,切换为英文(美国)作为默认语言/区域,重启终端或Android Studio后重新构建。
  • 临时在终端设置环境变量后执行构建命令:
    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
    npx react-native run-android
    
  • 在Android Studio中配置Gradle JVM参数:
    打开File > Settings > Build, Execution, Deployment > Build Tools > Gradle,在Gradle JVM options中添加:
    -Duser.language=en -Duser.country=US
    
  • 清理项目缓存后重新构建:
    cd android && ./gradlew clean
    cd .. && npx react-native run-android
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 12:59:30