5

I am trying to build my react-native project for android and getting the following error on Windows but its working on Mac.

$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1090 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Task :react-native-get-sms-android:generateDebugRFile FAILED

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.9/userguide/command_line_interface.html#sec:command_line_warnings
128 actionable tasks: 128 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-get-sms-android:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-get-sms-android:debugCompileClasspath'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :react-native-get-sms-android
      > Failed to list versions for com.facebook.react:react-native.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

* 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 24s

My Environment:

  • Windows 10 Home
  • React Native v66.4
  • NodeJS v12.18.1

Found solutions when googled about this error that bintray was down and its status could be tracked at https://status.bintray.com.

But building the project works fine on Mac environment, and at the same time, it is failing in Windows with Received status code 502 from server: Bad Gateway. Any clues on this weird behavior?

Surya
  • 971
  • 2
  • 17
  • 30
  • 1
    your Mac just has it cached – BooleanCheese Jan 12 '22 at 20:59
  • I posted a similar question. I have seen another similar question. I actually think the bintray server is down that serves the remote dependencies. – Scorb Jan 12 '22 at 21:20
  • 1
    It's because of the Bintray sunset. Please read this Blog `https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/` – Balaji L S Jan 13 '22 at 04:37
  • Update: Jcenter will still continue to be read only and it seems it was down but now back up accessible – Balaji L S Jan 13 '22 at 06:25
  • 2
    I have the same problem since today, do you have a solution ? :( How do I check that it is not a cache problem on my Mac @BooleanCheese ? thanks in advance :) – Gaylord.P Jan 16 '22 at 10:02

2 Answers2

0

If Osvaldo's solution doesn't work, another one is to update your dependency itself which relies on jcenter in its gradle at the current version.

In this case, it's react-native-get-sms-android. Updating it may free it from jcenter.

In my case, it was an old version of react-native-sqlite-2.

Yairopro
  • 9,084
  • 6
  • 44
  • 51
0

I had the same issue nad removing jcenter and adding maven solved my problem:

The android/build.gradle file:

repositories {
  + mavenCentral()
  google()
  - jcenter()
  gradlePluginPortal()
  
}
~ ~ ~
dependencies {
  ~ ~ ~

  + mavenCentral()
  google()
  - jcenter()
  + gradlePluginPortal()
  
  maven { URL 'https://www.jitpack.io' }
}

Hint: The + sign means add this line and the - means remove that line.

Hot news

Yesterday morning jcener was shutdown by Facebook, so in one of my cases because issue was inside a package in node_modules folder, I used the following solution instead of above to permanently remove whatever related to jcenter:

The android/build.gradle file of that package in node_modules folder:

all { ArtifactRepository repo ->
  if(repo instanceof MavenArtifactRepository){
    def url = repo.url.toString()
    if (url.startsWith('https://jcenter.bintray.com/')) {
      remove repo
    }
  }
}

To keep this node_modules changes in the production environment use patch-package.

AmerllicA
  • 29,059
  • 15
  • 130
  • 154