Home > Back-end >  Could not resolve org.webkit:android-jsc:
Could not resolve org.webkit:android-jsc:

Time:01-18

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?

CodePudding user response:

We also just ran into this. I believe JCenter is down right now. https://status.bintray.com/

CodePudding user response:

JCenter is deprecated and now READ ONLY. And it is getting offline sometimes causing issues with builds.

First of all, you need to update your build.gradle file to use mavenCentral() replacing Jcenter()

In case 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 no, if you are building in React-native using npm packages, you could potentially take advantage of patch-package library.

Sometimes, the libraries have not yet released the update removing JCenter from build.gradle.

In this case, you can apply the changes yourself using the Patch Package library. Documentation added in the end for reference.

  1. Go to node_modules/library-with-error/android/build.gradle
  2. Change jcenter() to mavenCentral()
  3. Run: npx patch-package library-with-error
  4. Git add, commit and push

Important: In case of dependencies (pom, jar) are not added to Maven, here are instructions on how to add: https://maven.apache.org/repository/guide-central-repository-upload.html. Add that to the PR with discussions to collaborate.

Notes:

  • Add --use-yarn to patch-package command in case your project uses Yarn.
  • Documentation using Patch package.
  •  Tags:  
  • Related