生成构建 android Expo 时出错(错误:Gradle 构建因未知错误而失败。有关更多信息,请参阅“运行 gradlew”阶段的日志)

问题描述 投票:0回答:1

我正在尝试使用 React-native 和 Expo 生成 Android 版本,但遇到以下错误:

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

部分日志:

10 errors
> Task :app:compileDebugJavaWithJavac FAILED
> Task :react-native-quick-base64:configureCMakeDebug[armeabi-v7a]
C/C++: CMake Warning (dev) in CMakeLists.txt:
C/C++:   No project() command is present.  The top-level CMakeLists.txt file must
C/C++:   contain a literal, direct call to the project() command.  Add a line of
C/C++:   code such as
C/C++:     project(ProjectName)
C/C++:   near the top of the file, but after cmake_minimum_required().
C/C++:   CMake is pretending there is a "project(Project)" command on the first
C/C++:   line.
C/C++: This warning is for project developers.  Use -Wno-dev to suppress it.
> Task :expo-modules-core:buildCMakeDebug[arm64-v8a]
> Task :react-native-reanimated:buildCMakeDebug[arm64-v8a]
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
612 actionable tasks: 612 executed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
BUILD FAILED in 7m 8s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

我运行了 expo-doctor 命令,但如您所见,它没有发现任何问题: 在此输入图片描述

在 gradle\wrapper 目录内的 gradle-wrapper.properties 文件中,我将发行版本更改为 8.2,因为我看到它是 Gradle 支持的最低版本。

distributionUrl=https://services.gradle.org/distributions/gradle-8.2-all.zip

android react-native gradle expo expo-build
1个回答
0
投票

在你的build.gradle中,将你的buildTooldVersion和compileSdkVersion更新到版本34:

您的编译版本应与目标版本相同或更高。否则,由于它面向更高版本,您的应用程序可能会尝试使用版本 34 中的 API,但会遇到问题,因为它是针对版本 33 编译的。Android 设备需要较新的 API,但您的应用程序是使用较旧的 API 创建的。

buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
© www.soinside.com 2019 - 2024. All rights reserved.