我使用以下命令创建新的react-native项目:
react-native init myProject
但是当我想使用以下命令在模拟器或真实设备上运行它时:
react-native run-android
我收到此错误,应用无法构建:
FAILURE: Build failed with an exception.
* What went wrong:
fresco/1.10.0/fresco-1.10.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/facebook/fresco/fresco
/1.10.0/fresco-1.10.0.pom'.
> Connect to 127.0.0.1:9595 [/127.0.0.1] failed: Connection refused:
connect
在build.gradle中,我添加了google(),但没有解决问题。 这是我的build.gradle:
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
maven { url "https://maven.google.com" }
jcenter()
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven { url "https://maven.google.com" }
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
请任何人帮助。
答案 0 :(得分:1)
最后我找到了答案。 我在Android Studio中打开项目的android文件夹,并尝试与代理和下载的相关依赖项同步项目。然后,我运行此命令并成功构建项目。
react-native run-android
答案 1 :(得分:0)
我遇到了这个问题,我可以通过使用代理来解决