facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.15k stars 24.32k forks source link

Gradle build failed with unknown error. #41321

Closed karimnyumba closed 11 months ago

karimnyumba commented 1 year ago

Description

Concern: I am encountering an issue when attempting to build an app bundle or APK using my Expo project with EAS. The error is related to Gradle and shows problems with React Native Reanimated and React Native Camera.

Error Log: Running 'gradlew :app:assembleRelease' in /home/expo/workingdir/build/android

Downloading https://services.gradle.org/distributions/gradle-8.0.1-all.zip

10%.

20%.

30%

40%.

50%

60%

70%.

80%.

90%.

100%

Welcome to Gradle 8.0.1!

Here are the highlights of this release:

For more details see https://docs.gradle.org/8.0.1/release-notes.html

To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/8.0.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.

Daemon will be stopped at the end of the build

Task :gradle-plugin:pluginDescriptors

Task :gradle-plugin:processResources

Task :gradle-plugin:compileKotlin

Task :gradle-plugin:compileJava NO-SOURCE

Task :gradle-plugin:classes

Task :gradle-plugin:jar

Task :gradle-plugin:inspectClassesForKotlinIC

Configure project :expo-modules-core

Checking the license for package NDK (Side by side) 23.1.7779620 in /home/expo/Android/Sdk/licenses

License for package NDK (Side by side) 23.1.7779620 accepted.

Preparing "Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)".

"Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)" ready.

Installing NDK (Side by side) 23.1.7779620 in /home/expo/Android/Sdk/ndk/23.1.7779620

"Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)" complete.

"Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)" finished.

Checking the license for package CMake 3.22.1 in /home/expo/Android/Sdk/licenses

License for package CMake 3.22.1 accepted.

Preparing "Install CMake 3.22.1 (revision: 3.22.1)".

"Install CMake 3.22.1 (revision: 3.22.1)" ready.

Installing CMake 3.22.1 in /home/expo/Android/Sdk/cmake/3.22.1

"Install CMake 3.22.1 (revision: 3.22.1)" complete.

"Install CMake 3.22.1 (revision: 3.22.1)" finished.

Configure project :expo

Using expo modules

Configure project :react-native-reanimated

No AAR for react-native-reanimated found. Attempting to build from source.

Android gradle plugin: 7.4.2

Gradle: 8.0.1

WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the gradle.properties file or use the new publishing DSL.

FAILURE: Build failed with an exception.

Could not determine the dependencies of task ':app:lintVitalReportRelease'.

Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.

Could not resolve project :react-native-camera.

 Required by:

     project :app

  > The consumer was configured to find a component for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2'. However we cannot choose between the following variants of project :react-native-camera:

      - generalReleaseRuntimeElements

      - mlkitReleaseRuntimeElements

    All of them match the consumer attributes:

      - Variant 'generalReleaseRuntimeElements' capability Perks:react-native-camera:unspecified declares a component for use during runtime, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':

          - Unmatched attributes:

              - Provides attribute 'com.android.build.api.attributes.ProductFlavor:react-native-camera' with value 'general' but the consumer didn't ask for it

              - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'generalRelease' but the consumer didn't ask for it

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

              - Provides attribute 'react-native-camera' with value 'general' but the consumer didn't ask for it

      - Variant 'mlkitReleaseRuntimeElements' capability Perks:react-native-camera:unspecified declares a component for use during runtime, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':

          - Unmatched attributes:

              - Provides attribute 'com.android.build.api.attributes.ProductFlavor:react-native-camera' with value 'mlkit' but the consumer didn't ask for it

              - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'mlkitRelease' but the consumer didn't ask for it

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

              - Provides attribute 'react-native-camera' with value 'mlkit' but the consumer didn't ask for it

    The following variants were also considered but didn't match the requested attributes:

      - Variant 'generalDebugApiElements' capability Perks:react-native-camera:unspecified declares a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2':

          - Incompatible because this component declares a component for use during compile-time, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component for use during runtime, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release'

          - Other compatible attribute:

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

      - Variant 'generalDebugRuntimeElements' capability Perks:react-native-camera:unspecified declares a component for use during runtime, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2':

          - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release'

          - Other compatible attribute:

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

      - Variant 'generalReleaseApiElements' capability Perks:react-native-camera:unspecified declares a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':

          - Incompatible because this component declares a component for use during compile-time and the consumer needed a component for use during runtime

          - Other compatible attribute:

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

      - Variant 'mlkitDebugApiElements' capability Perks:react-native-camera:unspecified declares a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2':

          - Incompatible because this component declares a component for use during compile-time, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component for use during runtime, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release'

          - Other compatible attribute:

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

      - Variant 'mlkitDebugRuntimeElements' capability Perks:react-native-camera:unspecified declares a component for use during runtime, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2':

          - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release'

          - Other compatible attribute:

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

      - Variant 'mlkitReleaseApiElements' capability Perks:react-native-camera:unspecified declares a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':

          - Incompatible because this component declares a component for use during compile-time and the consumer needed a component for use during runtime

          - Other compatible attribute:

              - Doesn't say anything about its target Java environment (preferred optimized for Android)

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.

BUILD FAILED in 3m 4s

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.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings

5 actionable tasks: 5 executed

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

err3 err4 err

React Native Version

0.72.6

Output of npx react-native info

System: OS: Windows 11 10.0.22621 CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz Memory: 1.57 GB / 7.75 GB

Binaries: Node: version: 18.18.0 path: C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: version: 10.2.2 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found

SDKs: Android SDK: Not Found Windows SDK: Not Found

IDEs: Android Studio: AI-223.8836.35.2231.10811636 Visual Studio: Not Found

Languages: Java: version: 18.0.1.1 path: C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE Ruby: Not Found

npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.6 wanted: 0.72.6 react-native-windows: Not Found

npmGlobalPackages: "react-native": Not Found

Android: hermesEnabled: Not found newArchEnabled: Not found

iOS: hermesEnabled: Not found newArchEnabled: Not found

Steps to reproduce

Try to use React native reanimated 3.3.0 with react native 0.72.6 and react native camera 4.2.1.

My package.json is as follows: { "name": "stickersmash", "version": "1.0.0", "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web" }, "dependencies": { "@react-native-async-storage/async-storage": "1.18.2", "@react-native-community/datetimepicker": "7.2.0", "@react-native-community/progress-bar-android": "^1.0.5", "@react-navigation/bottom-tabs": "^6.5.8", "@react-navigation/native": "^6.1.7", "@react-navigation/stack": "^6.3.17", "@rneui/themed": "^4.0.0-rc.8", "axios": "^1.5.1", "expo": "~49.0.8", "expo-barcode-scanner": "~12.5.3", "expo-checkbox": "~2.4.0", "expo-image-picker": "~14.3.2", "expo-linear-gradient": "~12.3.0", "expo-location": "~16.1.0", "expo-status-bar": "~1.6.0", "lottie-react-native": "5.1.6", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.72.6", "react-native-camera": "^4.2.1", "react-native-fontawesome": "^7.0.0", "react-native-gesture-handler": "~2.12.0", "react-native-image-crop-picker": "^0.40.0", "react-native-image-picker": "^7.0.0", "react-native-linking": "^0.0.0", "react-native-permissions": "^3.8.4", "react-native-progress": "^5.0.0", "react-native-qrcode-scanner": "^1.5.5", "react-native-reanimated": "~3.3.0", "react-native-root-toast": "^3.5.1", "react-native-screens": "~3.22.0", "react-native-svg": "13.9.0", "react-native-toast-message": "^2.1.6", "react-native-url-polyfill": "^2.0.0", "react-native-vector-icons": "^10.0.0", "react-native-web": "~0.19.6", "uuid": "^9.0.0", "expo-dev-client": "~2.4.11" }, "devDependencies": { "@babel/core": "^7.20.0", "react-native-dotenv": "^3.4.9" }, "private": true }

My eas.json: { "cli": { "version": ">= 5.6.0" }, "build": { "development": { "developmentClient": true, "distribution": "internal", "ios": { "resourceClass": "m1-medium" } }, "preview": { "distribution": "internal", "ios": { "resourceClass": "m1-medium" }, "android": { "buildType": "apk" } }, "production": { "ios": { "resourceClass": "m1-medium" } } }, "submit": { "production": {} } }

Snack, screenshot, or link to a repository

https://github.com/karimnyumba/Perks_FrontEnd.git

lixy01 commented 1 year ago

jdk version 11 is not 18

luisherdeth2020 commented 1 year ago

I have the same problem😥

Android build failed: Gradle build failed with unknown error. See logs for the "Run gradlew" (https://expo.dev/accounts/luisherdeth/projects/wikipadel/builds/98c8e1cc-1ea0-4688-a0a7-e0597cc56346#run-gradlew) phase for more information.

image

Nadine-Habicht commented 1 year ago

While trying to fix the errors (I am also working on the same project), I used the commands npm outdated then npm update to update all packages listed in the package.json file. I then run npx expo-doctor to diagnose and troubleshoot other issues and found none.

We used the code eas build -p android to build the aab file then converted it into an apk. But now the issue is that the app doesn't open. Any feedback (suggestions, questions, ...) would be greatly appreciated.

AnenIsaac commented 1 year ago

I had the same problem when working on a similar project. I have not found a solution.

Demidragon25 commented 1 year ago

I've also reached this problem while trying to build the app through expo, I managed to update the dependencies using expo-doctor and installed some missing dependencies which allowed me to succesfully build it, but after getting the aab file and converting it into an apk file it would not run.

github-actions[bot] commented 11 months ago
:warning: Issue is Related to Expo
:information_source: It looks like your issue is related to Expo and not React Native core. Please open your issue in Expo's repository. If you are able to create a repro that showcases that this issue is also happening in React Native vanilla, we will be happy to re-open.
cortinico commented 11 months ago

Closing as a Expo related issue. The problem is coming from react-native-camera and you should use Expo's tool to re-aling dependencies

Anshul2k17saini commented 8 months ago

While trying to fix the errors (I am also working on the same project), I used the commands npm outdated then npm update to update all packages listed in the package.json file. I then run npx expo-doctor to diagnose and troubleshoot other issues and found none.

We used the code eas build -p android to build the aab file then converted it into an apk. But now the issue is that the app doesn't open. Any feedback (suggestions, questions, ...) would be greatly appreciated.

npm install react-native-screens react-native-safe-area-context This command installs the react-native-screens and react-native-safe-area-context packages, which help resolve your issue as work for me

Abdullatif-Erfan commented 6 months ago

I encountered the same problem while working on a similar project. Upon examining the errors, I discovered three significant issues. 1: Gradle build failed with unknown error. See logs for the Run 2: Execution failed for task ':app:mergeReleaseResources'. 3: Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

The following tips resolved my problems.

1: Run these commands and verify for yourself that the packages are updated. a. npx expo-doctor
b. npx expo-doctor --fix-dependencies c. npx expo install –check OR npx expo install –fix 2: Log in to the expo.dev dashboard and identify the failed APK. Reset the cache and delete the failed build. 3: Check the file extensions of all your images. In my case, I had imported an image as a .png, but it should have been imported as a .gif. 4: Run the command "eas build --platform android" to successfully build the APK setup.

Akumuuu commented 6 months ago

idk how to fix this problem

Running 'gradlew :app:bundleRelease' in /home/expo/workingdir/build/android
Welcome to Gradle 8.0.1!
Here are the highlights of this release:
 - Improvements to the Kotlin DSL
- Fine-grained parallelism from the first build with configuration cache
 - Configurable Gradle user home cache cleanup
For more details see https://docs.gradle.org/8.0.1/release-notes.html
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/8.0.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
> Task :expo-dev-launcher-gradle-plugin:pluginDescriptors
> Task :expo-dev-launcher-gradle-plugin:processResources
> Task :gradle-plugin:pluginDescriptors
> Task :gradle-plugin:processResources
> Task :expo-dev-launcher-gradle-plugin:compileKotlin
> Task :expo-dev-launcher-gradle-plugin:compileJava NO-SOURCE
> Task :expo-dev-launcher-gradle-plugin:classes
> Task :expo-dev-launcher-gradle-plugin:jar
> Task :expo-dev-launcher-gradle-plugin:inspectClassesForKotlinIC
> Task :gradle-plugin:compileKotlin
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:classes
> Task :gradle-plugin:jar
> Task :gradle-plugin:inspectClassesForKotlinIC
> Configure project :app
ℹ️  Applying gradle plugin 'expo-dev-launcher-gradle-plugin' (expo-dev-launcher@2.4.15)
> Configure project :expo-modules-core
Warning: Errors during XML parse:
Warning: Additionally, the fallback loader failed to parse the XML.
Checking the license for package CMake 3.22.1 in /home/expo/Android/Sdk/licenses
License for package CMake 3.22.1 accepted.
Preparing "Install CMake 3.22.1 (revision: 3.22.1)".
"Install CMake 3.22.1 (revision: 3.22.1)" ready.
Installing CMake 3.22.1 in /home/expo/Android/Sdk/cmake/3.22.1
"Install CMake 3.22.1 (revision: 3.22.1)" complete.
"Install CMake 3.22.1 (revision: 3.22.1)" finished.
> Configure project :expo
Using expo modules
  - expo-constants (15.4.6)
- expo-dev-client (2.4.13)
  - expo-dev-launcher (2.4.15)
  - expo-dev-menu (3.2.4)
  - expo-file-system (16.0.9)
  - expo-font (11.10.3)
  - expo-json-utils (0.7.1)
  - expo-keep-awake (12.8.2)
  - expo-manifests (0.7.2)
  - expo-modules-core (1.11.13)
  - expo-modules-core$android-annotation (1.11.13)
- expo-modules-core$android-annotation-processor (1.11.13)
  - expo-splash-screen (0.20.5)
  - expo-system-ui (2.4.0)
> Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Android gradle plugin: 7.4.2
Gradle: 8.0.1
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
Checking the license for package Android SDK Build-Tools 30.0.3 in /home/expo/Android/Sdk/licenses
License for package Android SDK Build-Tools 30.0.3 accepted.
Preparing "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)".
"Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" ready.
Installing Android SDK Build-Tools 30.0.3 in /home/expo/Android/Sdk/build-tools/30.0.3
"Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" complete.
"Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" finished.
Checking the license for package Android SDK Platform 33 in /home/expo/Android/Sdk/licenses
License for package Android SDK Platform 33 accepted.
Preparing "Install Android SDK Platform 33 (revision: 3)".
"Install Android SDK Platform 33 (revision: 3)" ready.
Installing Android SDK Platform 33 in /home/expo/Android/Sdk/platforms/android-33
"Install Android SDK Platform 33 (revision: 3)" complete.
"Install Android SDK Platform 33 (revision: 3)" finished.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':expo-modules-core:compileReleaseRenderscript'.
> Could not resolve all task dependencies for configuration ':expo-modules-core:releaseCompileClasspath'.
   > Could not resolve com.facebook.fbjni:fbjni:0.5.1.
     Required by:
         project :expo-modules-core
      > Cannot find a version of 'com.facebook.fbjni:fbjni' that satisfies the version constraints:
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.fbjni:fbjni:0.5.1'
           Constraint path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.fbjni:fbjni:{strictly 0.3.0}' because of the following reason: releaseRuntimeClasspath uses version 0.3.0
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.react:react-android:0.72.10' (releaseVariantDefaultApiPublication) --> 'com.facebook.fbjni:fbjni:0.3.0'
   > Could not resolve com.facebook.fbjni:fbjni:{strictly 0.3.0}.
     Required by:
         project :expo-modules-core
      > Cannot find a version of 'com.facebook.fbjni:fbjni' that satisfies the version constraints:
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.fbjni:fbjni:0.5.1'
           Constraint path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.fbjni:fbjni:{strictly 0.3.0}' because of the following reason: releaseRuntimeClasspath uses version 0.3.0
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.react:react-android:0.72.10' (releaseVariantDefaultApiPublication) --> 'com.facebook.fbjni:fbjni:0.3.0'
   > Could not resolve com.facebook.fbjni:fbjni:0.3.0.
     Required by:
         project :expo-modules-core > com.facebook.react:react-android:0.72.10
      > Cannot find a version of 'com.facebook.fbjni:fbjni' that satisfies the version constraints:
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.fbjni:fbjni:0.5.1'
           Constraint path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.fbjni:fbjni:{strictly 0.3.0}' because of the following reason: releaseRuntimeClasspath uses version 0.3.0
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.13' --> 'com.facebook.react:react-android:0.72.10' (releaseVariantDefaultApiPublication) --> 'com.facebook.fbjni:fbjni:0.3.0'
* 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
BUILD FAILED in 2m 55s
10 actionable tasks: 10 executed
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

🤖 Android build failed: Gradle build failed with unknown error. See logs for the "Run gradlew"