I am trying to generate an Android build using React-native and Expo, but I have been encountering the following error:
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
Part of the log:
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.
I ran the expo-doctor command, but as you can see, it didn’t find any issues:
enter image description here
In the gradle-wrapper.properties file inside the gradlewrapper directory, I changed the distribution version to 8.2 because I saw that it is the minimum version supported by Gradle.
distributionUrl=https://services.gradle.org/distributions/gradle-8.2-all.zip
In your build.gradle, update your buildTooldVersion and your compileSdkVersion to version 34:
Your compile version should be the same as or higher than the target version. Otherwise, because it is targeting a higher version, your application may try to utilise an API from version 34 but will encounter problems because it was compiled for version 33. The Android device expects newer APIs, however your app was created using an older API.
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34