'Could not resolve org.webkit:android-jsc:+
I'm getting an error every time I try to run 'react-native run-android' or './gradlew bundleRelease' for my React Native project.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:collectReleaseDependencies'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve org.webkit:android-jsc:+.
Required by:
project :app
> Failed to list versions for org.webkit:android-jsc.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml'.
> Read timed out
* 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 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 37s
Here's my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 24
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "16.0.1"
}
repositories {
google()
mavenCentral()
mavenCentral()
}
dependencies {
classpath 'com.facebook.react:react-native:0.12.+'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
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")
}
maven {
// expo-camera bundles a custom com.google.android:cameraview
url "$rootDir/../node_modules/expo-camera/android/maven"
}
maven { url 'https://maven.google.com' }
maven { url 'https://www.jitpack.io' }
google()
jcenter()
}
}
I can't find any an information about why this is happening bar adding 'www.' to 'https://www.jitpack.io' but it already has that.
'react-native run-android' was working yesterday, since then I changed emulator and also changed java version.
Does anyone know why this is happening?
Solution 1:[1]
JCenter is going to shutdown and now is READ-ONLY. And it is getting offline often causing issues with builds and pipelines.
In summary
You will require to update your android/build.gradle
file to use mavenCentral()
instead of Jcenter()
.
As per Gradle documentation, JCenter is a mirror of Maven Central, so all of your dependencies should be there.
JCenter is a central artifact repository, like Maven Central. Software projects use JCenter to distribute their software to other people. JCenter also serves as a mirror for Maven Central, so any dependencies available on Maven Central are also available on JCenter (but not vice versa).
A few things to consider:
In case it is a library (e.g node_modules/react-native-appsflyer), pointing to Jcenter, that is giving you an error... I would advise you to check the library giving you an error has updated a new version with a fix. In case so, update to the new version to get the changes.
In case the library doesn't have versions with the fix, if you are building in React-native using npm packages, you could potentially take advantage of
patch-package
library. Because there will a possibility the libraries have not yet released the update removing JCenter frombuild.gradle
.
Applying the patch
You can apply the changes yourself using the Patch Package library. Documentation added in the end for reference.
- Go to
node_modules/library-with-error/android/build.gradle
- Change
jcenter()
tomavenCentral()
- Run:
npx patch-package library-with-error
- Git add, commit and push
Personal notes:
- I did advise the full removal of
JCenter
instead of adding MavenCentral() to the top because of the shutdown and that JCenter is often getting offline and giving timeout errors.
Based on the current timeline, builds that use JCenter will be able to resolve dependencies until February 1, 2022 without changes. After that date, there are no guarantees that you will be able to build your software if you continue to use JCenter."
- Also, Gradle is discouraging the usage of JCenter.
"To discourage new projects from using JCenter, we will be removing JCenter from our samples and init templates. The new default will be Maven Central. Gradle itself has no inherent tie to JCenter or Maven Central, so you can always switch any other repository of your choice. This change will be effective with the next Gradle release – Gradle 7.0."
- In case of dependencies (pom, jar) are not added to Maven, here are instructions on how to add. Add that to the PR with discussions to collaborate.
Useful Links
- Add
--use-yarn
topatch-package
command in case your project uses Yarn. - Documentation using Patch package.
Solution 2:[2]
We also just ran into this. I believe JCenter is down right now. https://status.bintray.com/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Alex |