React Native:Android“从服务器接收到状态代码 502:错误网关”,JCenter 和 Bintray 已停止使用

2024-01-02

请注意,这些是我发现有用的错误片段,以及以“出了什么问题”开头的片段。运行后npx react-native run-android --verbose(自从这个项目昨天工作以来,它一直有效,并且我的 Android 开发环境肯定设置正确):

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

然后,我删除了以下实例jcenter()在我的 android 文件夹的 build.gradle 文件中。我看了这个答案https://stackoverflow.com/a/70417675/13368695 https://stackoverflow.com/a/70417675/13368695它说要执行此操作,并删除其他两个 URL(我在任何文件中都没有)。结果是这样的,下次我跑的时候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

由于昨天这是有效的,所以这个答案https://stackoverflow.com/a/35433372/13368695 https://stackoverflow.com/a/35433372/13368695对我来说尝试使用代理没有意义,或者这是我的 ISP 阻止网站或互联网连接速度慢的问题。

编辑:我正在寻找一种方法来替换来自 JCenter、Bintray 和其他已经/即将变得不可用的软件包。

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
    }
}

这是 JCenter 的全局中断。您可以在此处监控状态https://status.gradle.com https://status.gradle.com它取代了 bintray 状态页面,该页面现在似乎已完全关闭并返回 502 错误。

世界标准时间 1 月 13 日 06:35 更新

JCenter现已恢复上线,系统已全面运行。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

React Native:Android“从服务器接收到状态代码 502:错误网关”,JCenter 和 Bintray 已停止使用 的相关文章

随机推荐