无法在本地运行react native应用程序

时间:2019-08-16 09:58:51

标签: react-native react-native-android

我使用react-native init FirstApp创建了一个示例项目,而当我尝试使用react-native run-android运行该应用程序时,出现以下错误:

失败:构建失败,并出现异常。

A problem occurred configuring root project 'MyFirstApp'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not download builder.jar (com.android.tools.build:builder:3.4.1)
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.4.1/builder-3.4.1.jar'.
         > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.4.1/builder-3.4.1.jar'.
            > Connect to dl.google.com:443 [dl.google.com/172.217.212.91, dl.google.com/172.217.212.190, dl.google.com/172.217.212.93, dl.google.com/172.217.212.136] failed: Connection timed out: connect
   > Could not download manifest-merger.jar (com.android.tools.build:manifest-merger:26.4.1)
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/manifest-merger/26.4.1/manifest-merger-26.4.1.jar'.
         > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/manifest-merger/26.4.1/manifest-merger-26.4.1.jar'.
            > Connect to dl.google.com:443 [dl.google.com/74.125.124.190, dl.google.com/74.125.124.93, dl.google.com/74.125.124.136, dl.google.com/74.125.124.91] failed: Connection timed out: connect```

Can somebody help me out here?

1 个答案:

答案 0 :(得分:0)

我通过设置代理配置获得了解决方案。 在gradle.properties文件中设置以下配置


# HTTP proxy configuration
systemProp.http.proxyHost=your.proxy.host
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password

# HTTPS proxy configuration
systemProp.https.proxyHost=your.proxy.host
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password