我使用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?
答案 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