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

Lav*_*aju 11 android react-native

我正在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
Run Code Online (Sandbox Code Playgroud)

tou*_*doy 4

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

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

buildscript {
repositories {

    google()
   jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'  
}
Run Code Online (Sandbox Code Playgroud)

}

更新

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

  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' }
    }
}
Run Code Online (Sandbox Code Playgroud)