无法解析配置':classpath'的所有文件

时间:2019-01-04 10:09:18

标签: android react-native react-native-android

我正在开发react-native的示例应用程序,当我运行android模拟器时,我遇到了这个问题,我的sdk工具版本是25,但是我不知道它是怎么得到这个问题的,请让我提出建议。

> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.1.0.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.1.0.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom'.
            > org.apache.http.ssl.SSLInitializationException: \Library\Java\Home\jre\lib\security\cacerts (The system cannot find the path specified)
      > Could not resolve com.android.tools.build:gradle:3.1.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom'.
            > org.apache.http.ssl.SSLInitializationException: \Library\Java\Home\jre\lib\security\cacerts (The system cannot find the path specified)
   > Could not resolve com.google.gms:google-services:3.2.0.
     Required by:
         project :
      > Could not resolve com.google.gms:google-services:3.2.0.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/3.2.0/google-services-3.2.0.pom'.
            > org.apache.http.ssl.SSLInitializationException: \Library\Java\Home\jre\lib\security\cacerts (The system cannot find the path specified)
      > Could not resolve com.google.gms:google-services:3.2.0.
         > Could not get resource 'https://jcenter.bintray.com/com/google/gms/google-services/3.2.0/google-services-3.2.0.pom'.
            > org.apache.http.ssl.SSLInitializationException: \Library\Java\Home\jre\lib\security\cacerts (The system cannot find the path specified)

* 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

3 个答案:

答案 0 :(得分:0)

您的项目无法访问URL以下载必要的库。这很可能是gradle配置问题。

像这样更改您的项目级别build.gradle文件:

buildscript {
repositories {

    google()
   jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'  
}

}

更新

如果它不起作用,也尝试以下操作:

  repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
        ...
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

答案 1 :(得分:0)

尝试使用

classpath 'com.android.tools.build:gradle:3.0.1'

然后 清理并重建。

答案 2 :(得分:0)

文件>使缓存无效并重新启动 它对我有用!