I am trying to do my first react-native run-android
but I get the following error:
FAILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring root project 'WithoutExpo'.Could not resolve all files for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.1.4.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.1.4.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'.
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Could not resolve com.android.tools.build:gradle:3.1.4.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'.
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
My build.gradle file is this:
// 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")
}
As you can see from the commented out lines, I have tried multiple combinations based to former answers here
The common denominator of every error message is the
java.lang.RuntimeException: Unexpected error:
java.security.InvalidAlgorithmParameterException: the trustAnchors
parameter must be non-empty
I have also tried cd android/ && gradlew clean, and I have also tried changing gradle versions to classpath. All with the same result.
Any suggestions?
Best Answer
Ran into this myself.
The android getting started documents aren't quite right.
Instead of installing Android 8.0 & SDK Platform 26.0.3, choose Android 8.1 & 27.0.3
Note this is for React-Native 0.57.3