本地EAS的生产与开发构建失败

移动开发 2026-07-12

因为我的Expo订阅是免费的,所以我达到了构建上限,因此必须在本地电脑上进行构建。

我执行了 npx eas build --platform android --profile production --local 命令,但出现了这个错误:

[RUN_GRADLEW] [Incubating] Problems report is available at: file:///private/tmp/eas-build-local-nodejs/74502f58-b790-4718-8ce2-5a99ed66dead/build/android/build/reports/problems/problems-report.html
[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * Where:
[RUN_GRADLEW] Build file '/private/tmp/eas-build-local-nodejs/74502f58-b790-4718-8ce2-5a99ed66dead/build/android/build.gradle' line: 24
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] A problem occurred evaluating root project 'easeview'.
[RUN_GRADLEW] > Failed to apply plugin 'com.facebook.react.rootproject'.
[RUN_GRADLEW]    > A problem occurred configuring project ':app'.
[RUN_GRADLEW]       > SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '/private/tmp/eas-build-local-nodejs/74502f58-b790-4718-8ce2-5a99ed66dead/build/android/local.properties'.
[RUN_GRADLEW] * Try:
[RUN_GRADLEW] > Run with --stacktrace option to get the stack trace.
[RUN_GRADLEW] > Run with --info or
[RUN_GRADLEW] --debug option to get more log output.
[RUN_GRADLEW] > Run with --scan to get full insights.
[RUN_GRADLEW] > Get more help at https://help.gradle.org.
[RUN_GRADLEW] Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
[RUN_GRADLEW] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
[RUN_GRADLEW] For more on this, please refer to https://docs.gradle.org/8.14.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
[RUN_GRADLEW] BUILD FAILED
[RUN_GRADLEW] in 5s
[RUN_GRADLEW] 32 actionable tasks: 32 executed
[RUN_GRADLEW] Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

Build failed
Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
    at resolveBuildPhas

我已经设置了ANDROID_HOME环境变量。事实上,我还尝试了expo prebuild: npx expo run:android,它构建成功。

解决方案

如果你已经做过以下操作:
npm install -g eas-cli

你可以尝试同样的命令,但前面不要加npx只要
eas build --platform android --profile production --local

备选方案

在你的 Android 文件夹中,创建一个名为 local.properties 的文件,内容如下。

sdk.dir=/Users/{user}/Library/Android/sdk

user 替换为实际的文件系统用户名。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章