【发布时间】:2019-02-27 22:33:28
【问题描述】:
我正在尝试做我的第一个react-native run-android,但我收到以下错误:
FAILURE:构建失败并出现异常。
- 出了什么问题:
配置根项目“WithoutExpo”时出现问题。
无法解析配置“:classpath”的所有文件。 无法解析 com.android.tools.build:gradle:3.1.4。 要求: 项目 : 无法解析 com.android.tools.build:gradle:3.1.4。 无法获取资源“https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom”。 无法获取“https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom”。 java.lang.RuntimeException:意外错误:java.security.InvalidAlgorithmParameterException:trustAnchors 参数必须为非空 无法解析 com.android.tools.build:gradle:3.1.4。 无法获取资源“https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom”。 无法获取“https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom”。 java.lang.RuntimeException:意外错误:java.security.InvalidAlgorithmParameterException:trustAnchors 参数必须为非空
我的 build.gradle 文件是这样的:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
// mavenCentral()
google()
// maven {
// url "https://maven.google.com"
// }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
正如您从注释掉的行中看到的那样,我根据以前的答案here尝试了多种组合
每个错误消息的共同点是
java.lang.RuntimeException:意外错误: java.security.InvalidAlgorithmParameterException:trustAnchors 参数必须为非空
我也尝试过 cd android/ && gradlew clean,我也尝试过将 gradle 版本更改为类路径。结果都一样。
有什么建议吗?
【问题讨论】:
标签: java android react-native