React Native - 运行Android - 找不到common.jar(android.arch.core:common:1.0.0)

Hay*_*meh 6 android gradle react-native

当运行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.
Run Code Online (Sandbox Code Playgroud)

小智 16

我发现这个解决方案对我有用:maven { url "https://maven.google.com" }在文件中添加第18行android/build.gradle

在此输入图像描述


Edd*_*his 5

如果您正在使用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()
    }
}
Run Code Online (Sandbox Code Playgroud)