问题描述
我最近开始使用react native,但是根据伊朗制裁,gradle无法构建我的第一个项目,因此我使用了VPN,还使用了 shecan服务,但出现以下错误:
I recently started to use react native, but according to Iranians Sanctions, gradle cannot build my first projects, so I used VPN and also shecan service but I get the following error:
我阅读了React本机指令并遵循它们,设置了一个模拟器,对本机cli进行响应,并提供了巧克力服务.在环境中,有人写道,我应该在名为PATH
的变量中定义SDK的platform-tools文件夹.但是在变量中,我已经在用户名和系统变量中有了路径.在编辑中,我已将平台工具添加到其中.但不幸的是,它还没有起作用.
I read React native instructions and followed them, set up an emulator, react native cli, and chocolaty service. In environments, it was written that I should define my platform-tools folder of my SDK in a variable named PATH
. But in variables, I have already had path in username and in system variables. In edit, I have added my platform-tools to them. But unfortunately it didn't work yet.
图像中的PowerShell错误消息是:
The PowerShell error messages in the image are:
PS C:\Others\RN_projects\React_native_shop\shop_project> react-native run-android
在设备上构建和安装应用程序(cd android&& gradlew.bat installDebug)...失败:生成失败,出现异常.
Building and installing the app on the device (cd android && gradlew.bat installDebug)... FAILURE: Build failed with an exception.
- 出了什么问题:配置根项目"shop_project"时发生问题.无法解析所有工件以进行配置 ':classpath'.无法解析com.android.tools.build:gradle:3.2.1.
- What went wrong: A problem occurred configuring root project 'shop_project'. Could not resolve all artifacts for configuration ':classpath'. Could not resolve com.android.tools.build:gradle:3.2.1.
要求者:
项目:无法解析com.android.tools.build:gradle:3.2.1. 无法获取资源 ' https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom ". 无法获取 ' https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom ". 连接到127.0.0.1:8580 [/127.0.0.1]失败:连接被拒绝: 连接
project : Could not resolve com.android.tools.build:gradle:3.2.1. Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. Connect to 127.0.0.1:8580 [/127.0.0.1] failed: Connection refused: connect
无法解析com.android.tools.build:gradle:3.2.1.
Could not resolve com.android.tools.build:gradle:3.2.1.
无法获取资源 ' https://jcenter .bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom ". 无法获取 ' https://jcenter .bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom '.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
连接到127.0.0.1:8580 [/127.0.0.1]失败:连接被拒绝: 连接
Connect to 127.0.0.1:8580 [/127.0.0.1] failed: Connection refused: connect
- 尝试:
使用--stacktrace选项运行以获取堆栈跟踪.使用--info运行 或--debug选项以获取更多日志输出.与--scan一起运行以获取完整信息 见解.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
- 在 https://help.gradle.org 上获取更多帮助.
- Get more help at https://help.gradle.org
在3秒钟内失败,无法在设备上安装该应用程序,请阅读 上面的错误以获取详细信息.确保您有一个Android模拟器 正在运行或已连接设备并已设置您的Android开发 环境: https://facebook.github.io/react-native/docs/Getting-started.html
BUILD FAILED in 3s Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html
events.js:173
events.js:173
投掷者;//未处理的错误"事件^错误:spawn cmd.exe ENOENT
throw er; // Unhandled 'error' event ^ Error: spawn cmd.exe ENOENT
在Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)在onErrorNT (internal/child_process.js:421:16)在processTicksAndRejections (内部/进程/next_tick.js:76:17)
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19) at onErrorNT (internal/child_process.js:421:16) at processTicksAndRejections (internal/process/next_tick.js:76:17)
在:Process.ChildProcess._handle.onexit处发出的错误"事件 (internal/child_process.js:252:12)在onErrorNT (internal/child_process.js:421:16)在processTicksAndRejections (内部/进程/next_tick.js:76:17)
Emitted 'error' event at: at Process.ChildProcess._handle.onexit (internal/child_process.js:252:12) at onErrorNT (internal/child_process.js:421:16) at processTicksAndRejections (internal/process/next_tick.js:76:17)
推荐答案
将此代理信息添加到您的gradle.properties
文件中:
Add this proxy information to your gradle.properties
file:
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).然后同步项目.
and set above proxy port (ex. 9595) in your vpn like psiphone.Then sync project.
这篇关于无法获取资源'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!