构建 Android React Native 时网关错误

Bad gateway when building Android React Native

当我 运行 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

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

现在有效。

我将我的更改时间重置为 master 并且它有效。把这个留给以后有这个错误的人——不要相信 bintray 状态页面,等一下。我在研究期间在某处读到它会无限期保持只读状态。

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

现在有来自 Intercom for React-Native 的 official library!它使用新的 mavenCentral 存储库,并且(我发现)它与 react-native-intercom 之间的差异很小。方法是一样的。您可能想迁移到它。

现在我遇到了这个问题,因为 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

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

文件:

./android/build.gradle

更改为:

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

Toggle Offline Mode Button

  1. 打开 Toggle Offline Mode(检查上图 link!)在 Gradle Window
  • 您可以通过单击右侧栏中的 Gradle 按钮打开 Gradle Window。
  1. Build > Clean ProjectFile > Invalidate Caches > (check) Clear file system cache and Local History > Invalidate and Restart
  2. File > Sync Project with Gradle Files

它在这些东西之后起作用。