expo: Expo modules build failed with Gradle version 8 in Bare workflow

Minimal reproducible example

classifier = ‘sources’

Summary

I installed expo modules in my react native bare workflow as per the documentation (Install Expo modules) to use some expo packages.

After upgrading my project to React Native v0.72.0 which is released recently and came with the Gradle version 8. The following packages are failing with this error while syncing the project when we run yarn android.

Could not set unknown property 'classifier' for task ':expo-application:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar

List of affected packages are

  • expo-application
  • expo-constants
  • expo-error-recovery
  • expo-file-system
  • expo-font
  • expo-keep-awake
  • expo-modules-core
  • expo-linear-gradient (not built-in one)

Fix

To fix the issue, we’ve to find every expo packages that include classifier = 'sources' in build.gradle file and should replace as follow.

diff --git a/node_modules/expo-application/android/build.gradle b/node_modules/expo-application/android/build.gradle
index c820f21..f022b35 100644
--- a/node_modules/expo-application/android/build.gradle
+++ b/node_modules/expo-application/android/build.gradle
@@ -37,7 +37,7 @@ buildscript {
 
 // Creating sources with comments
 task androidSourcesJar(type: Jar) {
-  classifier = 'sources'
+  archiveClassifier.set("sources")
   from android.sourceSets.main.java.srcDirs
 }

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.4 Shell: 5.9 - /bin/zsh Binaries: Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node Yarn: 3.6.0 - ~/.nvm/versions/node/v18.13.0/bin/yarn npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm Watchman: 2023.06.08.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.12.1 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: 14.3/14E222b - /usr/bin/xcodebuild npmPackages: expo: latest => 48.0.19 react: 18.2.0 => 18.2.0 react-native: 0.72.0 => 0.72.0 Expo Workflow: bare

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 14
  • Comments: 38 (6 by maintainers)

Commits related to this issue

Most upvoted comments

UPDATE: fixed after downgrading to gradle 7.5.1 from 8.0.1

android/gradle/wrapper/gradle-wrapper.properties

- distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip

Not sure why this was closed. This is still an issue even with Expo sdk 49

ℹ️  Applying gradle plugin 'expo-dev-launcher-gradle-plugin' (expo-dev-launcher@2.4.8)

 ℹ️  Applying gradle plugin 'expo-updates-gradle-plugin' (expo-updates@0.18.11)

[stderr] 

FAILURE: Build completed with 2 failures.

[stderr] 

1: Task failed with an exception.

[stderr] 

-----------

[stderr] 

* Where:

[stderr] 

Build file '/home/expo/workingdir/build/node_modules/expo-error-recovery/android/build.gradle' line: 40

[stderr] 

* What went wrong:

[stderr] 

A problem occurred evaluating project ':expo-error-recovery'.

[stderr] 

> Could not set unknown property 'classifier' for task ':expo-error-recovery:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.

[stderr] 

* Try:

[stderr] 

> Run with --stacktrace option to get the stack trace.

[stderr] 

> Run with

[stderr] 

--info or --debug option to get more log output.

[stderr] 

> Run with --scan to get full insights.

[stderr] 

==============================================================================

[stderr] 

2: Task failed with an exception.

[stderr] 

-----------

[stderr] 

* What went wrong:

[stderr] 

A problem occurred configuring project ':expo'.

[stderr] 

> compileSdkVersion is not specified. Please add it to build.gradle

[stderr] 

* Try:

[stderr] 

> Run with --stacktrace option to get the stack trace.

[stderr] 

> Run with --info or --debug option to get more log output.

[stderr] 

> Run with --scan to get full insights.

[stderr] 

==============================================================================

[stderr] 

* Get more help at https://help.gradle.org

[stderr] 

BUILD FAILED in 2m 2s

15 actionable tasks: 15 executed

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

My package.json


  "dependencies": {
    "@expo/vector-icons": "^13.0.0",
    "@expo/webpack-config": "^18.0.1",
    "@oclif/core": "^2.8.10",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-firebase/app": "^18.3.0",
    "@react-native-firebase/auth": "^18.3.0",
    "@react-navigation/bottom-tabs": "^6.5.8",
    "@react-navigation/material-top-tabs": "^6.6.3",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/native-stack": "^6.9.13",
    "@sentry-internal/tracing": "^7.57.0",
    "@sentry/cli": "^2.19.1",
    "@sentry/react-native": "5.5.0",
    "@yarnpkg/sdks": "^3.0.0-rc.46",
    "email-validator": "^2.0.4",
    "expo": "^49.0.0",
    "expo-application": "~5.3.0",
    "expo-asset": "~8.10.1",
    "expo-constants": "~14.4.2",
    "expo-dev-client": "~2.4.6",
    "expo-device": "~5.4.0",
    "expo-error-recovery": "^4.0.1",
    "expo-local-authentication": "~13.4.1",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "expo-updates": "~0.18.11",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-error-boundary": "^4.0.10",
    "react-native": "0.72.3",
    "react-native-confirmation-code-field": "^7.3.1",
    "react-native-exception-handler": "^2.10.10",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-get-random-values": "~1.9.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-pager-view": "6.2.0",
    "react-native-paper": "^5.8.0",
    "react-native-paper-tabs": "^0.7.0",
    "react-native-reanimated": "~3.3.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-tab-view": "^3.5.1",
    "react-native-vector-icons": "^9.2.0",
    "react-native-web": "~0.19.6",
    "sentry-expo": "~7.0.0",
    "vscode": "^1.1.37"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/plugin-transform-arrow-functions": "^7.0.0-0",
    "@babel/plugin-transform-shorthand-properties": "^7.0.0-0",
    "@babel/plugin-transform-template-literals": "^7.0.0-0",
    "@react-navigation/stack": "^5.5.1",
    "@tsconfig/react-native": "^3.0.2",
    "@types/jest": "^29.5.2",
    "@types/react": "~18.2.14",
    "@types/react-test-renderer": "^18.0.0",
    "babel-plugin-module-resolver": "^5.0.0",
    "babel-runtime": "^6.26.0",
    "typescript": "^5.1.3"
  },
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "format": "prettier --write src/app/**/*.{json,css,scss,less,md,ts,html}",
    "build:apk": "cd .android && chmod +x ./gradlew assembleRelease",
    "devdistribution": "eas build --profile preview --platform all"
  },
  "version": "1.0.0",
  "private": true,
  "name": "myapp"
}

Similar error here on SDK 50, RN 0.73.x

downgrading gradle to the proposed 7.5.1 caused:

> Failed to apply plugin class 'org.gradle.toolchains.foojay.FoojayToolchainsPlugin'.
   > FoojayToolchainsPlugin needs Gradle version 7.6 or higher

using 7.6.4 caused:

 > The new Java toolchain feature cannot be used at the project level in combination with source and/or target compatibility

Still occuring error after upgrading to expo@^49.0.0-beta.2 and react native 0.72.1

$ npm run build:android:release

> x@0.0.1 build:android:release
> cd android/ && ./gradlew assembleRelease && ./gradlew bundleRelease

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:
 - 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

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/workspaces/*/node_modules/@pchmn/expo-material3-theme/android/build.gradle' line: 40

* What went wrong:
A problem occurred evaluating project ':pchmn-expo-material3-theme'.
> Could not set unknown property 'classifier' for task ':pchmn-expo-material3-theme:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.

* 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:
A problem occurred configuring project ':expo'.
> compileSdkVersion is not specified. Please add it to build.gradle

* 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 1m 35s
5 actionable tasks: 5 executed

npx expo-env-info

$ npx expo-env-info

  expo-env-info 1.0.5 environment info:
    System:
      OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
      Shell: 5.0.17 - /bin/bash
    Binaries:
      Node: 19.7.0 - ~/nvm/current/bin/node
      Yarn: 1.22.19 - /usr/bin/yarn
      npm: 9.5.0 - ~/nvm/current/bin/npm
    SDKs:
      Android SDK:
        API Levels: 31, 33
        Build Tools: 30.0.3, 33.0.0
    npmPackages:
      expo: ^49.0.0-beta.2 => 49.0.0-beta.2 
      react: 18.2.0 => 18.2.0 
      react-native: 0.72.1 => 0.72.1 
    Expo Workflow: bare

I hit this issue after upgrading react-native to 0.72.

Looks like expo have made fixes in pre-release packages…setting my package.json to latest versions of those worked for me

    "expo": "~49.0.0-alpha.6",
    "expo-application": "~5.3.0",
    "expo-asset": "~8.9.1",
    "expo-camera": "~13.4.0",
    "expo-clipboard": "~4.3.0",
    "expo-constants": "~14.4.1",
    "expo-contacts": "~12.2.0",
    "expo-crypto": "~12.4.0",
    "expo-device": "~5.4.0",
    "expo-file-system": "~15.4.0",
    "expo-font": "~11.3.0",
    "expo-image-loader": "~4.3.0",
    "expo-image-manipulator": "~11.3.0",
    "expo-media-library": "~15.4.0",
    "expo-navigation-bar": "~2.3.0",
    "expo-status-bar": "~1.6.0",

I also had to bump kotlin version to 1.8.10, although im not sure if that’s related.

Followed these instructions for the build to succeed. I had to create patch packages for expo-firebase-* packages.

https://github.com/expo/fyi/blob/main/expo-modules-gradle8-migration.md

Just wait for the official update y’all, the expo team is updating the libraries one by one to fix compatibility with gradle 8. There are many issues like #23020 and #23011 which should be fixed before SDK 49 is released, so better not to clutter the issues section.

Similar error here on SDK 50, RN 0.73.x

downgrading gradle to the proposed 7.5.1 caused:

> Failed to apply plugin class 'org.gradle.toolchains.foojay.FoojayToolchainsPlugin'.
   > FoojayToolchainsPlugin needs Gradle version 7.6 or higher

using 7.6.4 caused:

 > The new Java toolchain feature cannot be used at the project level in combination with source and/or target compatibility

Just ran into the same issue after upgrading from Expo SDK 49. Did you solve the problem? I can’t create any builds at the moment

I ran several tests, fixed some things, and broke others. I tested it on 2 computers with different operating systems, Ubuntu and Fedora, and both presented the same issues. I decided to try it on a third system, Windows, which I have dual-booted on my computer, and it worked. My tests involved creating both a new project and using the project I’ve been working on for the past 2 months; in both cases, there were errors during the build process. There seems to be something going wrong when the project is built in a Linux environment. All the errors I observed are pointing to issues with the Gradle version, Java version, and Kotlin errors. I managed to address the Java and Gradle-related errors with the help of this issue, but I couldn’t resolve the Kotlin error in any way.

Same

`[CONFIGURE_EXPO_UPDATES] Setting the update request headers in ‘AndroidManifest.xml’ to ‘{“expo-channel-name”:“production”}’ [RUN_GRADLEW] Running ‘gradlew :app:assembleRelease’ in /var/folders/86/ly913pjd35lgg0dknyc_nlnw0000gn/T/eas-build-local-nodejs/1fe0d0b7-8f2d-413d-a7c2-511990185534/build/sergos-app/android [RUN_GRADLEW] FAILURE: Build failed with an exception. [RUN_GRADLEW] * What went wrong: [RUN_GRADLEW] A problem occurred configuring root project ‘sergos-app’. [RUN_GRADLEW] > [RUN_GRADLEW] Could not determine the dependencies of null. [RUN_GRADLEW] > [RUN_GRADLEW] Could not resolve all task dependencies for configuration ‘:classpath’. [RUN_GRADLEW] > [RUN_GRADLEW] Could not resolve expo.modules:expo-dev-launcher-gradle-plugin. [RUN_GRADLEW] Required by: [RUN_GRADLEW] project : [RUN_GRADLEW] > [RUN_GRADLEW] No matching variant of [RUN_GRADLEW] project :expo-dev-launcher-gradle-plugin [RUN_GRADLEW] was found. The consumer was configured to find [RUN_GRADLEW] a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘8.0.1’ [RUN_GRADLEW] but: [RUN_GRADLEW] - Variant ‘apiElements’ capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified declares [RUN_GRADLEW] a library, packaged as a jar, and its dependencies declared externally [RUN_GRADLEW] : [RUN_GRADLEW] - Incompatible because this component declares [RUN_GRADLEW] a component for use during compile-time, compatible with Java 11 [RUN_GRADLEW] and the consumer needed [RUN_GRADLEW] a component for use during runtime, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘mainSourceElements’ capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified declares [RUN_GRADLEW] a component, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares [RUN_GRADLEW] a component of category ‘verification’ [RUN_GRADLEW] and the consumer needed [RUN_GRADLEW] a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Doesn’t say anything about its usage (required runtime) [RUN_GRADLEW] - Variant ‘runtimeElements’ capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified declares [RUN_GRADLEW] a library for use during runtime, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘testResultsElementsForTest’ capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified: [RUN_GRADLEW] - Incompatible because this component declares a component of category ‘verification’ and the consumer needed a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about how its dependencies are found (required its dependencies declared externally) [RUN_GRADLEW] - Doesn’t say anything about its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Doesn’t say anything about its usage (required runtime) [RUN_GRADLEW] > Could not resolve expo.modules:expo-updates-gradle-plugin. [RUN_GRADLEW] Required by: [RUN_GRADLEW] project : [RUN_GRADLEW] > No matching variant of project :expo-updates-gradle-plugin was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘8.0.1’ but: [RUN_GRADLEW] - Variant ‘apiElements’ capability expo.modules:expo-updates-gradle-plugin:unspecified declares a library, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘mainSourceElements’ capability expo.modules:expo-updates-gradle-plugin:unspecified declares a component, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component of category ‘verification’ [RUN_GRADLEW] and the consumer needed [RUN_GRADLEW] a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] its usage (required runtime) [RUN_GRADLEW] - Variant ‘runtimeElements’ capability expo.modules:expo-updates-gradle-plugin:unspecified declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares [RUN_GRADLEW] a component, compatible with Java 11 [RUN_GRADLEW] and the consumer needed a component, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘testResultsElementsForTest’ capability expo.modules:expo-updates-gradle-plugin:unspecified: [RUN_GRADLEW] - Incompatible because this component declares a component of category ‘verification’ and the consumer needed [RUN_GRADLEW] a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] how its dependencies are found (required its dependencies declared externally) [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Doesn’t say anything about its usage (required runtime) [RUN_GRADLEW] > Could not resolve com.android.tools.build:gradle:7.4.2. [RUN_GRADLEW] Required by: [RUN_GRADLEW] project : [RUN_GRADLEW] > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find [RUN_GRADLEW] a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘8.0.1’ but: [RUN_GRADLEW] - Variant ‘apiElements’ capability com.android.tools.build:gradle:7.4.2 declares [RUN_GRADLEW] a library, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 [RUN_GRADLEW] and the consumer needed a component for use during runtime, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘javadocElements’ capability com.android.tools.build:gradle:7.4.2 declares a component for use during runtime, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares documentation and the consumer needed a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘runtimeElements’ capability com.android.tools.build:gradle:7.4.2 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘sourcesElements’ capability com.android.tools.build:gradle:7.4.2 declares a component for use during runtime, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares documentation and the consumer needed a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] > Could not resolve com.facebook.react:react-native-gradle-plugin. [RUN_GRADLEW] Required by: [RUN_GRADLEW] project : [RUN_GRADLEW] > No matching variant of project :gradle-plugin was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘8.0.1’ but: [RUN_GRADLEW] - Variant ‘apiElements’ capability com.facebook.react:react-native-gradle-plugin:unspecified declares a library, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘mainSourceElements’ capability com.facebook.react:react-native-gradle-plugin:unspecified declares a component, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component of category ‘verification’ and the consumer needed a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Doesn’t say anything about its usage (required runtime) [RUN_GRADLEW] - Variant ‘runtimeElements’ capability com.facebook.react:react-native-gradle-plugin:unspecified declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: [RUN_GRADLEW] - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8 [RUN_GRADLEW] - Other compatible attribute: [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Variant ‘testResultsElementsForTest’ capability com.facebook.react:react-native-gradle-plugin:unspecified: [RUN_GRADLEW] - Incompatible because this component declares a component of category ‘verification’ and the consumer needed a library [RUN_GRADLEW] - Other compatible attributes: [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] how its dependencies are found (required its dependencies declared externally) [RUN_GRADLEW] - Doesn’t say anything about [RUN_GRADLEW] its target Java version (required compatibility with Java 8) [RUN_GRADLEW] - Doesn’t say anything about its elements (required them packaged as a jar) [RUN_GRADLEW] - Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.0.1’) [RUN_GRADLEW] - Doesn’t say anything about its usage (required runtime) [RUN_GRADLEW] * Try: [RUN_GRADLEW] > Run with --stacktrace option to get the stack trace. [RUN_GRADLEW] > [RUN_GRADLEW] Run with [RUN_GRADLEW] --info [RUN_GRADLEW] or --debug option to get more log output. [RUN_GRADLEW] > [RUN_GRADLEW] Run with --scan to get full insights. [RUN_GRADLEW] * Get more help at https://help.gradle.org [RUN_GRADLEW] BUILD FAILED [RUN_GRADLEW] in 4s [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. npx exited with non-zero code: 1 Error: build command failed.`

How can I resolve that please ?

I hit this issue after upgrading react-native to 0.72.

Looks like expo have made fixes in pre-release packages…setting my package.json to latest versions of those worked for me

    "expo": "~49.0.0-alpha.6",
    "expo-application": "~5.3.0",
    "expo-asset": "~8.9.1",
    "expo-camera": "~13.4.0",
    "expo-clipboard": "~4.3.0",
    "expo-constants": "~14.4.1",
    "expo-contacts": "~12.2.0",
    "expo-crypto": "~12.4.0",
    "expo-device": "~5.4.0",
    "expo-file-system": "~15.4.0",
    "expo-font": "~11.3.0",
    "expo-image-loader": "~4.3.0",
    "expo-image-manipulator": "~11.3.0",
    "expo-media-library": "~15.4.0",
    "expo-navigation-bar": "~2.3.0",
    "expo-status-bar": "~1.6.0",

I also had to bump kotlin version to 1.8.10, although im not sure if that’s related.

This worked for me, not this specific list but installing every package that gave error.

If for whatever reasons you still need to use some deprecated native modules, I have created a repo with patch files to save some time: https://github.com/paradite/rn-patch-package

Currently I have:

  • expo-ads-admob
  • expo-firebase-analytics
  • expo-firebase-core
  • expo-firebase-core/node_modules/expo-constants

@Tjax33 - it could be that you are running into this error because expo-error-recovery was deprecated in sdk 46 and hasn’t been upgraded since (~10 months). from the README:

Deprecated. This module will be removed in SDK 47. This package is not utilized in projects built outside of the deprecated classic build system (expo build:ios & expo build:android). For similar functionality, use the built-in error handling of expo-updates. You can also use a third-party crash reporting service like Sentry or Bugsnag with EAS Build.

@brentvatne this still seems to be a bug and the workaround from @yuameshi means it still doesn’t work with gradle 8

@saty9 nope. it completely solved by upgrading an expo module (expo-material3-theme (sry about that ive forgotten the exact name of the module))

i means if an expo module still dont support gradle 8, u can use older gradle 7 instead.