我正在尝试运行react-native run-android但我不断得到这个错误。我在模拟器上运行。我使用FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'AwesomeProject'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
:AwesomeProject:unspecified
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tool
/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/buil
/gradle/2.2.3/gradle-2.2.3.pom'. Received status code 407 from server:
Proxy Authentication Required
启动了该应用。
PS:我在代理上运行。
当我试图运行时
react-native run-android
我明白了:
Error:Could not GET
'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-
2.2.3.pom'. Received status code 407 from server: Proxy Authentication
Required
<a href="toggle.offline.mode">Enable Gradle 'offline mode' and sync
project</a>
当我试图运行时
直接在Android Studio中
我明白了:
private void writeLogFile(string textInLog)
{
//Creating a streamwriter to write to the file with the path of logFileName.
using (var sw = new StreamWriter(logFileName))
{
sw.WriteLine(textInLog);
}
}
我已经安装了node_modules,我不知道还有什么可以尝试的,我一直在谷歌搜索过去4个小时并且什么都没有。
答案 0 :(得分:3)
在sdk manager中设置代理详细信息
AndroidStudio-&gt; tools-&gt; Android-&gt; SDKManager-&gt;系统设置 - &gt; Http代理
答案 1 :(得分:2)
您的问题与npm和节点无关。你有一些gradle问题。检查你是否可以从浏览器访问URL?
https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle- 2.2.3.pom
答案 2 :(得分:2)
它清楚地说<a href="toggle.offline.mode">Enable Gradle 'offline mode' and sync
project</a>
。
您是否尝试过启用离线模式?
如果没有,试试这个:
转到文件 - &gt;设置。
然后打开'构建,执行,部署',然后打开'构建工具' - &gt; '摇篮'。
然后取消选中右侧的“离线工作”。
单击“确定”按钮。
然后重建项目。
对于Mac,请转到AndroidStudio - &gt;偏好,休息是一样的。
答案 3 :(得分:2)
尝试在gradle.properties中添加这些:
systemProp.http.proxyHost=proxyURL
systemProp.http.proxyPort=proxyPort
systemProp.http.proxyUser=USER
systemProp.http.proxyPassword=PASSWORD
systemProp.https.proxyHost=proxyUrl
systemProp.https.proxyPort=proxyPort
systemProp.https.proxyUser=USER
systemProp.https.proxyPassword=PASSWORD