我刚刚将 Android Studio 从 1.5 升级到 2.0(即安装了全新版本)。升级似乎进行得很顺利,但是当我打开项目时,当 Gradle 同步我的项目时,我遇到了问题。
Gradle 同步运行几分钟后,我收到此错误:
Failed to sync Gradle project MyProject
Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy settings in Gradle.
Error: Enable Gradle "offline mode' and sync project
Learn about configuring HTTP proxies in Gradle
因此,我点击了以下链接:
Enable Gradle "offline mode' and sync project
然后 Gradle 旋转一两秒,我现在收到以下消息:
Failed to sync Gradle project MyProject
Error: No cached version of com.android.tools.build:gradle:1.3.0 available for offline mode.
Disable Gradle 'offline mode' and sync project
所以,我点击这个链接:
Disable Gradle 'offline mode' and sync project
我又回到了我的第一个错误。
我正在使用的机器 100% 离线。它没有、也永远不会有任何类型的网络连接。我想我需要禁用某种需要互联网的检查,但我不确定是什么。这个问题可以修复吗?还是我必须降级回 Android Studio 1.5?
UPDATE
我也收到此错误消息:
Gradle sync failed: Unknown host 'services.gradle.org'. You may need to adjust the proxy settings in Gradle.
好的,我解决了我的问题,所以我想发布我是如何做到的,以防其他人遇到这种情况。
我在谷歌上搜索了一下找到一个声明 https://www.quora.com/Can-I-use-Android-Studio-offline关于使用 Android Studio 离线工作,内容如下:
您可以,但是您将无法使用任何 Gradle 依赖项。 Gradle 使用互联网搜索存储库中的依赖项,因此如果您完全无法在线工作。尽量不要在 Gradle 文件中包含任何内容,如果这样做,则必须同步它并且会失败。基本上只要不碰 Gradle 文件就可以了。
因此,我查看了我的 gradle 文件,特别是项目的 build.gradle(而不是模块)。到了那里,我注意到一行:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
所以,我更换了1.3.0
with 2.0.0
项目建设得很好。
我希望这对将来的其他人有帮助。祝你好运。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)