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

React Native项目构建Release AAB失败:expo-updates编译报错

React Native 构建Release AAB失败问题

问题描述

我想要为React Native项目构建Release AAB包,已按照React Native文档完成所有步骤,但仍无法成功。执行expo eject导出代码后,运行cd android && ./gradlew bundleRelease命令持续失败,报错信息如下:

FAILURE: Build completed with 2 failures.
1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':expo-updates:compileReleaseKotlin'.

Compilation error. See log for more details

  • 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.
    2: Task failed with an exception.
  • What went Wrong:
    java.lang.StackOverflowError (no error message)

  • 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.

Execution optimizations have been disabled for 2 invalid units of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
BUILD FAILED in 5m 21s
333 actionable tasks: 5 executed, 328 up-to-date

解决方法

1. 获取详细错误日志

先运行带参数的命令定位具体问题:

cd android && ./gradlew bundleRelease --stacktrace

或用--info/--debug获取更多编译细节,重点关注:expo-updates模块的Kotlin编译报错点。

2. 解决StackOverflowError

该错误多因Gradle堆内存不足,修改android/gradle.properties文件增大堆内存:

org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

若已有此配置,调大-Xmx的值(比如从2048m改为4096m)。

3. 检查expo-updates版本兼容性

expo eject后可能存在版本不匹配问题,更新expo-updates到适配版本:

npm install expo-updates@latest

更新后重新同步Gradle。

4. 清理构建缓存

清理旧缓存避免冲突:

cd android && ./gradlew clean
rm -rf ~/.gradle/caches

之后重新运行./gradlew bundleRelease。

5. 统一Kotlin版本

确保项目Kotlin版本与expo-updates兼容,查看android/build.gradle中的配置:

buildscript {
    ext {
        kotlinVersion = "1.8.0" // 调整为与expo-updates适配的版本
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

调整版本后重新构建。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 21:45:39