react-native-ultimate-config
react-native-ultimate-config copied to clipboard
Build Failure - RN 0.69.1
Describe the bug
Configure project :react-native-ultimate-config 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.
-
Where: Build file '/Users/nikhilpatel/ovs-projects/Bitbucket/yourzone-frontend/node_modules/react-native-ultimate-config/android/build.gradle' line: 113
-
What went wrong: A problem occurred configuring project ':react-native-ultimate-config'.
Could not resolve all files for configuration ':react-native-ultimate-config:implementation'. Could not resolve com.facebook.react:react-native:+. Required by: project :react-native-ultimate-config > Cannot choose between the following variants of com.facebook.react:react-native:0.69.1: - debugVariantDefaultRuntimePublication - releaseVariantDefaultRuntimePublication All of them match the consumer attributes: - Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.69.1: - Unmatched attributes: - Provides com.android.build.api.attributes.BuildTypeAttr 'debug' but the consumer didn't ask for it - Provides org.gradle.category 'library' but the consumer didn't ask for it - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it - Provides org.gradle.libraryelements 'aar' but the consumer didn't ask for it - Provides org.gradle.status 'release' but the consumer didn't ask for it - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it - Variant 'releaseVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.69.1: - Unmatched attributes: - Provides com.android.build.api.attributes.BuildTypeAttr 'release' but the consumer didn't ask for it - Provides org.gradle.category 'library' but the consumer didn't ask for it - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it - Provides org.gradle.libraryelements 'aar' but the consumer didn't ask for it - Provides org.gradle.status 'release' but the consumer didn't ask for it - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
- 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.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/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
Steps to Reproduce
Steps to reproduce the behavior.
Build Android project using RN 0.69.1
Expected behavior
Project Builds successfully
Stacktraces, logs, screenshots
Post stacktraces, logs or screenshots. The more information is available is better.
Environment
See reactnative.dev for RN 0.69.1
Integration option
- [ ] I am using
rnuc
CLI to inject environment (default integration option from quickstart guide) - [ ] I am using scheme/flavor based integration (experimental integration option from cookbook: scheme, flavors)
- [ ] I am using
react-native-ultimate-config
within monorepo managed with Lerna or Yarn Workspaces Monorepo support
Env file
- [ ] I am using dotenv file as a source for variables
- [ ] I am using YAML file as a source for variables
Example of env file that is causing problems
❗PROVIDE EXAMPLE OF ENV FILE
OS
- [ ] ios
- [ ] android
Packages
- version of
react-native
: ❗ INSERT VERSION HERE - version of
react-native-ultimate-config
: ❗INSERT VERSION HERE
Run react-native info
and post below:
PASTE OUTPUT OF `react-native info` HERE
Additional context
Add any other context about the problem here.
I also encountered that issue, however that code seems to be related only to maven publishing. Workaround with patch-package:
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
- project.getConfigurations().implementation.setCanBeResolved(true)
- classpath += files(project.getConfigurations().getByName('implementation').asList())
+ // https://github.com/maxkomarychev/react-native-ultimate-config/issues/107
+ // This is only for publishing to maven, so commenting it out does not affect app
+ // project.getConfigurations().implementation.setCanBeResolved(true)
+ // classpath += files(project.getConfigurations().getByName('implementation').asList())
include '**/*.java'
}
i think i have the same problem, when I try to compile with version 69.1 of react native it gives me this error. :(
`* What went wrong: A problem occurred configuring project ':react-native-ultimate-config'.
Could not resolve all files for configuration ':react-native-ultimate-config:implementation'. Could not resolve com.facebook.react:react-native:+. Required by: project :react-native-ultimate-config > Cannot choose between the following variants of com.facebook.react:react-native:0.69.1: - debugVariantDefaultRuntimePublication - releaseVariantDefaultRuntimePublication All of them match the consumer attributes: - Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.69.1: - Unmatched attributes: - Provides com.android.build.api.attributes.BuildTypeAttr 'debug' but the consumer didn't ask for it - Provides org.gradle.category 'library' but the consumer didn't ask for it - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it - Provides org.gradle.libraryelements 'aar' but the consumer didn't ask for it - Provides org.gradle.status 'release' but the consumer didn't ask for it - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it - Variant 'releaseVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.69.1: - Unmatched attributes: - Provides com.android.build.api.attributes.BuildTypeAttr 'release' but the consumer didn't ask for it - Provides org.gradle.category 'library' but the consumer didn't ask for it - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it - Provides org.gradle.libraryelements 'aar' but the consumer didn't ask for it - Provides org.gradle.status 'release' but the consumer didn't ask for it - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it`
I also encountered that issue, however that code seems to be related only to maven publishing. Workaround with patch-package:
task androidJavadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += files(android.bootClasspath) - project.getConfigurations().implementation.setCanBeResolved(true) - classpath += files(project.getConfigurations().getByName('implementation').asList()) + // https://github.com/maxkomarychev/react-native-ultimate-config/issues/107 + // This is only for publishing to maven, so commenting it out does not affect app + // project.getConfigurations().implementation.setCanBeResolved(true) + // classpath += files(project.getConfigurations().getByName('implementation').asList()) include '**/*.java' }
This works for me!
react-native 0.70.0 same issue
The library does not work for the latest RN versions (> 69.0) on android (iOS seems fine)
Same with react-native 0.70.4
Today I build successful with react-native 0.70.4 using patch-package for the project I'm working on.
Here is the diff that solved my problem (from intothefire fork):
diff --git a/node_modules/react-native-ultimate-config/android/build.gradle b/node_modules/react-native-ultimate-config/android/build.gradle
index 7ba78ad..36c107a 100644
--- a/node_modules/react-native-ultimate-config/android/build.gradle
+++ b/node_modules/react-native-ultimate-config/android/build.gradle
@@ -10,17 +10,7 @@
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
-def DEFAULT_COMPILE_SDK_VERSION = 28
-def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
-def DEFAULT_MIN_SDK_VERSION = 16
-def DEFAULT_TARGET_SDK_VERSION = 28
-
-def safeExtGet(prop, fallback) {
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
-}
-
apply plugin: 'com.android.library'
-apply plugin: 'maven-publish'
buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -41,122 +31,112 @@ buildscript {
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
-android {
- compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
- buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
- defaultConfig {
- minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
- targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
- versionCode 1
- versionName "1.0"
- }
- lintOptions {
- abortOnError false
- }
-}
-repositories {
- // ref: https://www.baeldung.com/maven-local-repository
- mavenLocal()
- maven {
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
- url "$rootDir/../node_modules/react-native/android"
- }
- maven {
- // Android JSC is installed from npm
- url "$rootDir/../node_modules/jsc-android/dist"
- }
- google()
- jcenter()
+def getExtOrDefault(name) {
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNAndroidNotificationListener_' + name]
}
-dependencies {
- //noinspection GradleDynamicVersion
- implementation 'com.facebook.react:react-native:+' // From node_modules
+def getExtOrIntegerDefault(name) {
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RNAndroidNotificationListener_' + name]).toInteger()
}
-def configureReactNativePom(def pom) {
- def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
-
- pom.project {
- name packageJson.title
- artifactId packageJson.name
- version = packageJson.version
- group = "com.reactnativeultimateconfig"
- description packageJson.description
- url packageJson.repository.baseUrl
-
- licenses {
- license {
- name packageJson.license
- url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
- distribution 'repo'
- }
- }
+android {
- developers {
- developer {
- id packageJson.author.username
- name packageJson.author.name
- }
- }
- }
-}
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
-afterEvaluate { project ->
- // some Gradle build hooks ref:
- // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
- task androidJavadoc(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- classpath += files(android.bootClasspath)
- project.getConfigurations().implementation.setCanBeResolved(true)
- classpath += files(project.getConfigurations().getByName('implementation').asList())
- include '**/*.java'
+ defaultConfig {
+ minSdkVersion getExtOrIntegerDefault('minSdkVersion')
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
+ versionCode 1
+ versionName "1.0"
- }
+ }
- task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
- classifier = 'javadoc'
- from androidJavadoc.destinationDir
+ buildTypes {
+ release {
+ minifyEnabled false
}
+ }
+ lintOptions {
+ disable 'GradleCompatible'
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
- task androidSourcesJar(type: Jar) {
- classifier = 'sources'
- from android.sourceSets.main.java.srcDirs
- include '**/*.java'
+repositories {
+ mavenCentral()
+ google()
+
+ def found = false
+ def defaultDir = null
+ def androidSourcesName = 'React Native sources'
+
+ if (rootProject.ext.has('reactNativeAndroidRoot')) {
+ defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
+ } else {
+ defaultDir = new File(
+ projectDir,
+ '/../../../node_modules/react-native/android'
+ )
+ }
+
+ if (defaultDir.exists()) {
+ maven {
+ url defaultDir.toString()
+ name androidSourcesName
}
- android.libraryVariants.all { variant ->
- def name = variant.name.capitalize()
- def javaCompileTask = variant.javaCompileProvider.get()
+ logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
+ found = true
+ } else {
+ def parentDir = rootProject.projectDir
+
+ 1.upto(5, {
+ if (found) return true
+ parentDir = parentDir.parentFile
+
+ def androidSourcesDir = new File(
+ parentDir,
+ 'node_modules/react-native'
+ )
+
+ def androidPrebuiltBinaryDir = new File(
+ parentDir,
+ 'node_modules/react-native/android'
+ )
+
+ if (androidPrebuiltBinaryDir.exists()) {
+ maven {
+ url androidPrebuiltBinaryDir.toString()
+ name androidSourcesName
+ }
- task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
- from javaCompileTask.destinationDir
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
+ found = true
+ } else if (androidSourcesDir.exists()) {
+ maven {
+ url androidSourcesDir.toString()
+ name androidSourcesName
}
- }
- artifacts {
- archives androidSourcesJar
- archives androidJavadocJar
- }
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
+ found = true
+ }
+ })
+ }
+
+ if (!found) {
+ throw new GradleException(
+ "${project.name}: unable to locate React Native android sources. " +
+ "Ensure you have you installed React Native as a dependency in your project and try again."
+ )
+ }
+}
- task installArchives(type: Upload) {
- configuration = configurations.archives
- // Honestly I have no idea maven works, it looks like the new solution should look somewhat like
- // so, but the pom is no longer available as a global variable under this setup
- publishing {
- repositories {
- maven {
- url "file://${projectDir}/../android/maven"
-// configureReactNativePom pom
- }
- }
- }
-// This no longer works in
-// repositories.mavenDeployer {
-// // Deploy to react-native-event-bridge/maven, ready to publish to npm
-// repository url: "file://${projectDir}/../android/maven"
-// configureReactNativePom pom
-// }
- }
+dependencies {
+ //noinspection GradleDynamicVersion
+ implementation "com.facebook.react:react-native:+"
}
@vagnerlandio Thanks! Unblocked me when migrating to react-native 0.70.5
@mateusz1913's solution above works for me and seems much simpler than @vagnerlandio's. What's the difference between these approaches and is either better or worse?
@marcshilling I provided only a workaround which disables some code regarding maven publishing. I didn't check whole @vagnerlandio solution, but it seems to be more complete solution. I don't have an idea which is better, as I didn't use that library for a longer time
@marcshilling I consider @mateusz1913 solution to be better, as it has fewer modifications and solves the problem.
Thinking about it, I will delete my solution, because it has many modifications, new bugs may appear.
Have any solution without editing on node-modules like this? I have the same issue like this
Have any solution without editing on node-modules like this? I have the same issue like this
Hi, anyone here?
Have any solution without editing on node-modules like this? I have the same issue like this
Hi, anyone here?
You can fork the project, edit the necessary file, commit and add the package to the project from the fork using yarn add https://github.com/HenryLee2703/react-native-ultimate-config
Have any solution without editing on node-modules like this? I have the same issue like this
Hi, anyone here?
You can fork the project, edit the necessary file, commit and add the package to the project from the fork using
yarn add https://github.com/HenryLee2703/react-native-ultimate-config
maybe it's a not good solution. I'm working in a project with a lot of people, they can depend on me and otherwise. Maybe the author of this library should have some adjusting on this library, he should update the library follow up by the latest version of react native. it's out of date
@maxkomarychev Do you have thoughts on the patch from @mateusz1913? Would there be a way to merge a variation of that without breaking the Maven publishing process?
By the amount of unanswered messages in this and other opened issues, I presume that the author has paused development and maintenance of the package.
I have dozens of published applications that depend on this package so I created a fork of the project, renamed it and published it on npm as react-native-awesome-config (v4.1.1)
This new version has the following changes:
- package updated with support for version 0.71.0 of react-native.
- example project updated to version 0.71.0 of react-native.
- example-web project updated for version 18.2.0 of reactjs.
- Fixes for build on ios
- Fixes for build on android.
- All tests pass 100% coverage
- Dependencies updated to the latest stable versions.
- Other small changes, nothing significant.
Obs: The project was renamed, but I kept the "rnuc" command for better compatibility.
hey @vagnerlandio would you like opening a PR here and/or getting more permissions in the project to avoid fragmentation?
p.s. you are correct, I was not able to allocate enough time to keep up with all incoming issues and challenges and I'm willing to add more people to work on this project!
By the amount of unanswered messages in this and other opened issues, I presume that the author has paused development and maintenance of the package.
I have dozens of published applications that depend on this package so I created a fork of the project, renamed it and published it on npm as react-native-awesome-config (v4.1.1)
This new version has the following changes:
- package updated with support for version 0.71.0 of react-native.
- example project updated to version 0.71.0 of react-native.
- example-web project updated for version 18.2.0 of reactjs.
- Fixes for build on ios
- Fixes for build on android.
- All tests pass 100% coverage
- Dependencies updated to the latest stable versions.
- Other small changes, nothing significant.
Obs: The project was renamed, but I kept the "rnuc" command for better compatibility.
Hi @vagnerlandio , how about react native version 0.70.6? Does the react-native-awesome-config support this version. I've init a project with many dependencies of version 0.70.6 . Thank you
hey @vagnerlandio would you like opening a PR here and/or getting more permissions in the project to avoid fragmentation?
p.s. you are correct, I was not able to allocate enough time to keep up with all incoming issues and challenges and I'm willing to add more people to work on this for project!
would be great. And then I delete the version I pushed to npm
By the amount of unanswered messages in this and other opened issues, I presume that the author has paused development and maintenance of the package. I have dozens of published applications that depend on this package so I created a fork of the project, renamed it and published it on npm as react-native-awesome-config (v4.1.1) This new version has the following changes:
- package updated with support for version 0.71.0 of react-native.
- example project updated to version 0.71.0 of react-native.
- example-web project updated for version 18.2.0 of reactjs.
- Fixes for build on ios
- Fixes for build on android.
- All tests pass 100% coverage
- Dependencies updated to the latest stable versions.
- Other small changes, nothing significant.
Obs: The project was renamed, but I kept the "rnuc" command for better compatibility.
Hi @vagnerlandio , how about react native version 0.70.6? Does the react-native-awesome-config support this version. I've init a project with many dependencies of version 0.70.6 . Thank you
I tested only in versions 0.70.0
, 0.70.1
, 0.7.4
and 0.71.0
.
As it worked in the latest version so I believe it will also work in this version 0.70.6
@vagnerlandio could you please open a pr from the top of your master, I will allocate some time to review changes this week and figure out logistics related to collaboration in this repository and publishing new versions. thanks!
@vagnerlandio could you please open a pr from the top of your master, I will allocate some time to review changes this week and figure out logistics related to collaboration in this repository and publishing new versions. thanks!
Thanks for your paying attention about our issues, u can review above answers to resolve the issues, hope u push a new version resolved issue asap
@HenryLee2703 is that the fix that is confirmed to work in this particular case https://github.com/maxkomarychev/react-native-ultimate-config/issues/107#issuecomment-1211395294 ?
@HenryLee2703 is that the fix that is confirmed to work in this particular case #107 (comment) ?
What fixing do you mean?
@vagnerlandio could you please open a pr from the top of your master, I will allocate some time to review changes this week and figure out logistics related to collaboration in this repository and publishing new versions. thanks!
OK, by the end of the week I will do that, I will also do a review on the changes I made, although it works in react-native version 0.71.0 I found a problem in an app that uses an older version. I'll analyze further and then fix it if necessary. (maybe the problem is in my app and not in the package)
p.s. you are correct, I was not able to allocate enough time to keep up with all incoming issues and challenges and I'm willing to add more people to work on this project!
@maxkomarychev I'd be happy to help maintain - I can at least support the web functionality that I added awhile back. You've created by far the best RN config package out there and I'd love to see it live on.
@maxkomarychev I've opened the pull request #128 . Please review and let me know if there are any changes that need to be made before it can be merged.
@elliotdickison can you test the maven publishing process in this pull request? In my tests, gradle test
, gradle build
and gradle publish
worked perfectly.
@HenryLee2703 You could also test if the #128 solves your related issue?
Thanks!
There was a massive refactoring made to the library and this problem could have been fixed in a new version 4.1.0-alpha.0 (https://github.com/maxkomarychev/react-native-ultimate-config/pull/128)
Please give it a try!! Thank you!
@elliotdickison @vagnerlandio I value your contribution and willingness to support this project! I am figuring out logistics related to permissions & workflows when adding more people to the repository.
Stay tuned!
Closing this for now.