构建 Android React Native 时出现错误的网关

Posted

技术标签:

【中文标题】构建 Android React Native 时出现错误的网关【英文标题】:Bad gateway when building Android React Native 【发布时间】:2022-01-07 13:04:42 【问题描述】:

当我运行react-native run-android 时,我收到以下错误:

* What went wrong:
Could not determine the dependencies of task ':react-native-intercom:generateDebugRFile'.
> Could not resolve all task dependencies for configuration ':react-native-intercom:debugRuntimeClasspath'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :react-native-intercom
      > Failed to list versions for com.facebook.react:react-native.
         > Unable to load Maven meta-data from https://dl.bintray.com/intercom/intercom-maven/com/facebook/react/react-native/maven-metadata.xml.
            > Could not get resource 'https://dl.bintray.com/intercom/intercom-maven/com/facebook/react/react-native/maven-metadata.xml'.
               > Could not GET 'https://dl.bintray.com/intercom/intercom-maven/com/facebook/react/react-native/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

我看到其他人遇到过类似的问题,他们说要检查状态:https://status.bintray.com/ - 但它表示一切正常。我还为 bintray 搜索了整个代码库,但没有引用它。

编辑: 还在浏览器中尝试了该 URL 并获得相同的 502

还有:

dara@dara-beast:~/DAD/rn-app$ curl http://dl.bintray.com/intercom/intercom-maven/com/facebook/react/react-native/maven-metadata.xml
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>


dara@dara-beast:~/DAD/rn-app$ curl https://dl.bintray.com/
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>

更新 看来 bintray 已经“落日”了,所以我不希望它回来。我已将 jcenter() 替换为 mavenCentral(),这似乎有所帮助,但我仍然收到如下错误:

* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.facebook.yoga:proguard-annotations:1.14.1.
     Searched in the following locations:
       - file:/home/dara/.m2/repository/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - file:/home/dara/DAD/rn-app/node_modules/react-native/android/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - file:/home/dara/DAD/rn-app/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
       - https://maven.google.com/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
       - https://sdk.squareup.com/public/android/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
     Required by:
         project :app > com.facebook.react:react-native:0.63.4
   > Could not find com.facebook.fbjni:fbjni-java-only:0.0.3.
     Searched in the following locations:
       - file:/home/dara/.m2/repository/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - file:/home/dara/DAD/rn-app/node_modules/react-native/android/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - file:/home/dara/DAD/rn-app/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
       - https://maven.google.com/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
       - https://sdk.squareup.com/public/android/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.63.4

我试图在构建文件中排除瑜伽和其他人,但它不起作用。我不知道该怎么办。

【问题讨论】:

您的问题解决了吗?突然遇到这个问题,直到昨天它工作正常 不,虽然它现在给我的是 403 而不是 503 【参考方案1】:

我不建议依赖 JCenter,过去几周它一直不稳定。

现在有一个来自 Intercom 的 official library 用于 React-Native!它使用的是新的mavenCentral repo,这和react-native-intercom 之间几乎没有区别(我发现)。方法是一样的。您可能想迁移到它。

【讨论】:

哦,太好了!不幸的是,我依赖的其他库使用 JCenter,所以我想我现在必须继续使用它。不过我不知道那个库!!谢谢!! 同舟共济!别无选择,只能等待 RN 库更新其依赖项。 (或者也许我们可以强制它?) 改用那个官方图书馆对我有用!谢谢@NishantNair 至少,有一个非迁移的方法。在之前的库中存在:Intercom.presentCarousel。并且在新库中,相同的方法具有不同的名称:Intercom.displayCarousel 另一个已弃用:displayConversationsList【参考方案2】:

现在可以了。

我将更改时间重置为 master 并且它有效。将这里留给以后遇到此错误的人-不要相信 bintray 状态页面,请稍等。我在研究期间的某个地方读到它会无限期地保持只读状态。

【讨论】:

更新 - 它又发生了。这次我通过离线解决了它,所以它依赖于缓存。上次它没有工作大概是因为我清除了我的缓存 我可以同意它再次发生。很遗憾,我们无法关注任何更新来检查它何时会得到解决。最好尽快更新到替代解决方案。 同样的问题。 dl.bintray.com/microsoftazuremobile/SDK/com/facebook/react/… -- 收到 502 错误。 status.jfrog.io 看起来 bintray 已经收到此错误的报告并正在修复。 如果有帮助,我跑了./gradlew assembleRelease --offline【参考方案3】:

我现在遇到了这个问题,因为 jcenter 的日落似乎提前了 2 个月。 https://status.bintray.com/

帮助解决这个问题会很棒。添加 mavenCentral() 并没有帮助,将 gradle 升级到 v6.9 并将 React Native 版本升级到 0.65.0。也没有帮助。

我仍然收到错误:

> Failed to list versions for com.facebook.react:react-native.
     > Unable to load Maven meta-data from https://google.bintray.com/flexbox-layout/com/facebook/react/react-native/maven-metadata.xml.
        > Could not get resource 'https://google.bintray.com/flexbox-layout/com/facebook/react/react-native/maven-metadata.xml'.
           > Could not GET 'https://google.bintray.com/flexbox-layout/com/facebook/react/react-native/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

【讨论】:

【参考方案4】:

我使用新的 maven,它为我工作

文件:

./android/build.gradle

改为:

maven  url 'https://repo1.maven.org/maven2/' 

【讨论】:

以上是关于构建 Android React Native 时出现错误的网关的主要内容,如果未能解决你的问题,请参考以下文章

如何从我的 react-native 项目构建 android apk?

react-native-pdf iOS 和 Android 构建错误

React Native - 在 Android 上构建 react-native-camera 错误

部署由React-Native开发的android和IOS应用程序

尝试在 Android 上运行我的 React Native 应用程序时出错

React-native 项目构建失败:找不到 com.android.tools.lint:lint-gradle:26.1.0