【问题标题】:React Native - Run Android - Could not find common.jar (android.arch.core:common:1.0.0) [duplicate]React Native-运行Android-找不到common.jar(android.arch.core:common:1.0.0)[重复]
【发布时间】:2018-05-28 13:53:20
【问题描述】:

当运行 react-native run-android 时,我得到了这个错误:

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-device-info'.
      > Could not find common.jar (android.arch.core:common:1.0.0).
        Searched in the following locations:
            https://jcenter.bintray.com/android/arch/core/common/1.0.0/common-1.0.0.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

【问题讨论】:

    标签: android react-native gradle


    【解决方案1】:

    我找到了 this 解决方案并为我工作: 在文件android/build.gradle的第18行添加maven { url "https://maven.google.com" }

    【讨论】:

    • 对我来说,这可以编译项目,但在 Android 上,应用程序在打开时崩溃。您的应用是否正常运行?
    • 是的,完美运行
    • 啊,只是因为添加这个存储库会自动更新 play-services-base 和 play-services-maps 的版本。需要在 build.gradle 上更改它
    • @MaurícioAraldi 添加 maven url 后,您是如何解决应用程序崩溃的?
    • 我们今天也遇到了同样的问题,似乎托管 common.jar 的 bintray 镜像不同步或其他问题 - 有些请求有效,但大多数无效。
    【解决方案2】:

    如果您使用的是jcenter()maven {url "https://maven.google.com"},请确保首先编写maven {url "https://maven.google.com"}(代码中的上部)。

    android.arch.core:common:1.0.0 存在于jcenter() 中,但那里没有.jar 文件,这就是构建失败的原因。使用 Google Maven 首先解决了这个问题,因为那里存在 .jar。

    allprojects {
        repositories {
            maven { url 'https://maven.google.com' } // <--- This needs to be before jcenter().
            jcenter()
        }
    }
    

    【讨论】:

    • 我把它作为你的代码。但是还是不行
    • 这是正确的。在jcenter 之前订购maven 意味着它将首先尝试查找maven 上的库依赖关系,并且只有当它在maven 上不可用时才会尝试jcenter
    • 这正是破坏一切的原因。谢谢!
    • @Eddwhis 在添加 react native fbsdk 后我也面临同样的问题,在我的android/build.gradle 中我没有看到所有项目,所以我应该添加那个或者我应该在哪里添加那行?跨度>
    • @Mafijul - 你试过清理项目吗?还是 Android Studio “使缓存无效并重新启动”?
    【解决方案3】:

    就我而言,这是我的 Wifi(代理...)的网络问题。例如,尝试使用移动数据切换网络。

    【讨论】:

      【解决方案4】:

      我将我的根项目构建 gradle 版本和所有支持库更新到最新版本并且它现在可以工作了,你可以检查它是否通过 build.gradle(root project) -> buildscript -> dependencies-> classpath ->

      classpath 'com.android.tools.build:gradle:3.your_latest_version'
      

      还要确保您的 compileSdkVersionbuildToolsVersion 是最新的

      并且从 gradle-wrapper.properties 文件中检查 distributionUrl 的版本

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-07
        • 2019-03-04
        • 2022-08-02
        • 2019-03-28
        • 2019-05-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多