【问题标题】:react-native Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml' [duplicate]react-native 无法 HEAD \'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml\' [重复]
【发布时间】:2022-11-04 19:48:24
【问题描述】:

我昨天创建了构建,它工作正常。但是当我今天尝试创建发布版本时,我得到了这个。一些如果这里已经问过的问题

这些问题是 android 特有的,react-native 的新用户不容易理解它们。所以这就是为什么我在这里问另一个专门针对 react-native 用户的问题。

我上面提到的问题的答案在某些特定情况下会有所帮助,但是在某些情况下反应原生时它没有帮助,例如 node_modules 中的某些依赖项。

添加上述解释是因为问题被标记为重复。

构建将继续,但强烈建议您将项目更新为 使用经过 compileSdk = 33 测试的更新的 Android Gradle 插件

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':react-native-community_masked-view:verifyReleaseResources'.
> Could not resolve all task dependencies for configuration ':react-native-community_masked-view:releaseRuntimeClasspath'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :react-native-community_masked-view
      > 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'.
               > Read timed out

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 45s
5 actionable tasks: 5 up-to-date

我认为这个问题是由于 jcenter deprecation 造成的。 jcenter 的任何可能的解决方案或替代方案。这适用于有许多依赖项并且您必须更改的 react-native 项目。

【问题讨论】:

标签: react-native android-studio jcenter


【解决方案1】:

从几个小时的研究如果最终发现。这是一个问题,因为 jcenter 已关闭。 根据 [official documentation][1] jcenter deprericated 和 Bintray/JCenter users should start migrating to a new hosting solution. 解决方案是从build file 中删除 jcenter 并将其替换为

mavenCentral() // <- add it

对于 react-native 用户 jcenter() 可能存在于您最近安装的某些依赖项中。检查 jcenter 在android-studio 中打开您的项目以轻松检查所有build.gradle 文件。

另一个解决方案是断开您的系统与互联网的连接并构建您的项目。在您启动项目后,将您的系统重新连接到互联网。 [1]:https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/

【讨论】:

  • 面对类似的问题,对我没有用。
  • 请检查我编辑的答案。替换所有依赖项后,它对我来说效果很好。
  • 是的,我必须在所有依赖项中替换它。谢谢。
  • 还是不行
  • 我想你错过了一些东西。在 android studio 中打开你的项目并检查所有的构建文件
【解决方案2】:

jcenter 已关闭,因此在它上线之前,临时解决方案只是断开与 Internet 的连接并构建您的项目,一旦构建完成并且应用程序启动,您就可以重新连接。

【讨论】:

  • 需要检查这是否有效
【解决方案3】:

问题来自于 jcenter 的关闭。如果您删除应用程序的存储库,如果您声明某些jcenter(),您将收到错误。

最好的方法是合并 PR 并更新这些依赖项的版本,但这可能需要一段时间。

同时,您可以在 android/build.gradle 中添加以下内容:

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

这修复了我所有的构建。

【讨论】:

  • 你确定这属于android/app/build.gradle 而不是android/build.gradle
  • 你是对的对不起!更新
【解决方案4】:

@PhilippeAuriach 的解决方案是为 react-native 修复它! 我添加了这个:

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

对我的安卓/build.gradle经过数小时的研究后工作正常! (感谢@PhilippeAuriach)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-12
    • 2022-12-19
    • 2020-05-02
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多