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
- update build.gradle fix https://github.com/expo/expo/issues/23023 — committed to iPagar/react-native-mobilesdk-module by iPagar a year ago
UPDATE: fixed after downgrading to gradle 7.5.1 from 8.0.1
android/gradle/wrapper/gradle-wrapper.propertiesNot sure why this was closed. This is still an issue even with Expo sdk 49
My package.json
Similar error here on SDK 50, RN 0.73.x
downgrading gradle to the proposed 7.5.1 caused:
using 7.6.4 caused:
Still occuring error after upgrading to
expo@^49.0.0-beta.2and react native 0.72.1npx expo-env-info
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
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.
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 ?
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:
@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:
@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.