React Native: Android "Received status code 502 from server: Bad Gateway" from JCenter and Bintray being discontinued

Note that these are snippets of the errors I found useful, and also that the snippets starting with "What went wrong". After running npx react-native run-android --verbose (which has always worked and my android dev environment is definitely set up correctly since this project worked yesterday):

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :app
         project :app > project :react-native-firebase_app
         project :app > project :react-native-firebase_auth
         project :app > project :react-native-google-signin_google-signin
         project :app > project :expo
         project :app > project :react-native-fbsdk-next
         project :app > project :react-native-gesture-handler
         project :app > project :react-native-safe-area-context
         project :app > project :react-native-screens
         project :app > project :expo > project :expo-modules-core
         project :app > project :expo > project :expo-splash-screen
         project :app > project :expo > project :expo-updates
      > 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

Then, I removed the instances of jcenter() in the build.gradle file of my android folder. I looked at this answer https://stackoverflow.com/a/70417675/13368695 and it said to do this, as well as, remove the other two URLs (which I didn't have in any file). What resulted was this, the next time I ran npx react-native run-android --verbose:

Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
> Task :app:checkDebugAarMetadata FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.facebook.flipper:flipper:0.54.0.
     Searched in the following locations:
       - file:/Users/daggerpov/.m2/repository/com/facebook/flipper/flipper/0.54.0/flipper-0.54.0.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/react-native/android/com/facebook/flipper/flipper/0.54.0/flipper-0.54.0.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/jsc-android/dist/com/facebook/flipper/flipper/0.54.0/flipper-0.54.0.pom
       - https://dl.google.com/dl/android/maven2/com/facebook/flipper/flipper/0.54.0/flipper-0.54.0.pom
       - https://repo.maven.apache.org/maven2/com/facebook/flipper/flipper/0.54.0/flipper-0.54.0.pom
       - https://www.jitpack.io/com/facebook/flipper/flipper/0.54.0/flipper-0.54.0.pom
     Required by:
         project :app
   > Could not find com.facebook.flipper:flipper-network-plugin:0.54.0.
     Searched in the following locations:
       - file:/Users/daggerpov/.m2/repository/com/facebook/flipper/flipper-network-plugin/0.54.0/flipper-network-plugin-0.54.0.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/react-native/android/com/facebook/flipper/flipper-network-plugin/0.54.0/flipper-network-plugin-0.54.0.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/jsc-android/dist/com/facebook/flipper/flipper-network-plugin/0.54.0/flipper-network-plugin-0.54.0.pom
       - https://dl.google.com/dl/android/maven2/com/facebook/flipper/flipper-network-plugin/0.54.0/flipper-network-plugin-0.54.0.pom
       - https://repo.maven.apache.org/maven2/com/facebook/flipper/flipper-network-plugin/0.54.0/flipper-network-plugin-0.54.0.pom
       - https://www.jitpack.io/com/facebook/flipper/flipper-network-plugin/0.54.0/flipper-network-plugin-0.54.0.pom
     Required by:
         project :app
   > Could not find com.facebook.flipper:flipper-fresco-plugin:0.54.0.
     Searched in the following locations:
       - file:/Users/daggerpov/.m2/repository/com/facebook/flipper/flipper-fresco-plugin/0.54.0/flipper-fresco-plugin-0.54.0.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/react-native/android/com/facebook/flipper/flipper-fresco-plugin/0.54.0/flipper-fresco-plugin-0.54.0.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/jsc-android/dist/com/facebook/flipper/flipper-fresco-plugin/0.54.0/flipper-fresco-plugin-0.54.0.pom
       - https://dl.google.com/dl/android/maven2/com/facebook/flipper/flipper-fresco-plugin/0.54.0/flipper-fresco-plugin-0.54.0.pom
       - https://repo.maven.apache.org/maven2/com/facebook/flipper/flipper-fresco-plugin/0.54.0/flipper-fresco-plugin-0.54.0.pom
       - https://www.jitpack.io/com/facebook/flipper/flipper-fresco-plugin/0.54.0/flipper-fresco-plugin-0.54.0.pom
     Required by:
         project :app
   > Could not find com.facebook.yoga:proguard-annotations:1.14.1.
     Searched in the following locations:
       - file:/Users/daggerpov/.m2/repository/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/react-native/android/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/jsc-android/dist/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - https://dl.google.com/dl/android/maven2/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - https://repo.maven.apache.org/maven2/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - https://www.jitpack.io/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
     Required by:
         project :app > com.facebook.react:react-native:0.64.3
   > Could not find com.facebook.fbjni:fbjni-java-only:0.0.3.
     Searched in the following locations:
       - file:/Users/daggerpov/.m2/repository/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/react-native/android/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - file:/Users/daggerpov/Documents/GitHub/GuestApplication/node_modules/jsc-android/dist/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - https://dl.google.com/dl/android/maven2/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - https://repo.maven.apache.org/maven2/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - https://www.jitpack.io/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
     Required by:
         project :app > com.facebook.react:react-native:0.64.3
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

Since this was working yesterday, this answer https://stackoverflow.com/a/35433372/13368695 doesn't make sense for me to try using a proxy, or that it's an issue with my ISP blocking the website or a slow internet connection.

EDIT: I am looking for a way to replace the packages that come from JCenter, Bintray, and other ones that have/are going to become unusable soon.

android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")

        classpath 'com.google.gms:google-services:4.3.10' //added for Firebase

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))
        }
        maven {
            // Android JSC is installed from npm
            url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../dist"))
        }

        google() //for Firebase, Google's Maven repository
        mavenCentral()
        maven { url 'https://www.jitpack.io' }
    }
}

android/app/build.gradle:

dependencies {
    //adding Firebase BoM:
    implementation platform('com.google.firebase:firebase-bom:29.0.2')
    // Add the dependency for the Firebase SDK for Google Analytics
    // When using the BoM, don't specify versions in Firebase dependencies
    implementation 'com.google.firebase:firebase-analytics'
    // TODO Add the dependencies for any other desired Firebase integrations
    // https://firebase.google.com/docs/android/setup#available-libraries



    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules

    def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
    def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
    def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";

    // If your app supports Android versions before Ice Cream Sandwich (API level 14)
    // All fresco packages should use the same version
    if (isGifEnabled || isWebpEnabled) {
        implementation 'com.facebook.fresco:fresco:2.0.0'
        implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
    }

    if (isGifEnabled) {
        // For animated gif support
        implementation 'com.facebook.fresco:animated-gif:2.0.0'
    }

    if (isWebpEnabled) {
        // For webp support
        implementation 'com.facebook.fresco:webpsupport:2.0.0'
        if (isWebpAnimatedEnabled) {
            // Animated webp support
            implementation 'com.facebook.fresco:animated-webp:2.0.0'
        }
    }
    
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-debug.aar"))
        releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-release.aar"))
    } else {
        implementation jscFlavor
    }
}

1 answer

  • answered 2022-01-13 08:18 Gevorg Sahakyan

    it's a global outage in JCenter. You can monitor status here https://status.gradle.com it replaces bintray status page which seems is now fully sunset and returns 502 error.

    UPDATE Jan 13, 06:35 UTC

    JCenter is now back online, systems are fully operational.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum