React Native项目未成功构建

时间:2019-03-14 09:16:23

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

我是React Native的新手,我创建了一个新的react-native项目。 但是当我想在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:8081[/127.0.0.1] failed: Connection refused:
 connect

如何解决此问题?请帮我。谢谢

1 个答案:

答案 0 :(得分:1)

将此代理信息添加到您的gradle.properties文件中:

systemProp.https.proxyPort=9595
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=9595

并在psiphone之类的vpn中设置高于代理端口(例如9595)。然后同步项目。

mavenCentral()添加到您的build.gradle项目中,如下所示:

buildscript {
    repositories {

        google()
        jcenter()
        mavenCentral()
        maven {
            name 'Sonatype SNAPSHOTs'
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }


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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()

        maven { url 'https://jitpack.io' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        flatDir {
            dirs 'libs'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}