Android “没有缓存版本……可用于离线模式。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22607661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"No cached version... available for offline mode."
提问by robin
I received an error message while building a new Hello World project in Android Studio:
在 Android Studio 中构建新的 Hello World 项目时收到错误消息:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MyApplication2'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:0.9.1.
Required by:
:MyApplication2:unspecified
> No cached version of com.android.tools.build:gradle:0.9.1 available for offline mode.
BUILD FAILED
Android Studio version: 0.5.2
安卓工作室版本:0.5.2
Gradle version: 0.9.1
摇篮版本:0.9.1
I'm using a proxy connection to Internet.
我正在使用代理连接到 Internet。
回答by friedrich
Had the same error after updating Android Studio today. For me, it wasn't a matter of proxy settings:
今天更新 Android Studio 后出现同样的错误。对我来说,这不是代理设置的问题:
Uncheck "Offline work" in Android Studio 0.6.0:
File->Settings->Gradle->Global Gradle Settings
or in OSX:
Preferences->Gradle->Global Gradle Setting
or in more recent versions:
File->Settings->Build, Execution, Deployment->Build tools->Gradle
Resync the project, for example by restarting the Android Studio
- Once synced, you can check the option again to work offline.
在 Android Studio 0.6.0 中取消选中“离线工作”:
文件->设置->Gradle->全局Gradle设置
或在 OSX 中:
Preferences->Gradle->Global Gradle Setting
或在更新的版本中:
文件->设置->构建、执行、部署->构建工具->Gradle
重新同步项目,例如通过重新启动 Android Studio
- 同步后,您可以再次选中该选项以脱机工作。
(Only tested in Gradle version 0.11... and Android Studio version 0.6.0 Preview)
(仅在 Gradle 0.11 版...和 Android Studio 0.6.0 版预览版中测试)
EDIT :Added paths for different versions/platforms (as mentioned by John Ballingerand The_Martian). Not yet verified.
编辑:为不同版本/平台添加了路径(如John Ballinger和The_Martian 所述)。尚未验证。
回答by jeprubio
回答by Martin Melka
Just happened to me after upgrading to Android Studio 3.1. The Offline Work checkbox was unchecked, so no luck there.
升级到 Android Studio 3.1 后发生在我身上。脱机工作复选框未选中,所以没有运气。
I went to Settings > Build, Execution, Deployment > Compiler
and the Command-line Options
textfield contained --offline
, so I just deleted that and everything worked.
我去了Settings > Build, Execution, Deployment > Compiler
,Command-line Options
文本字段包含--offline
,所以我只是删除了它,一切正常。
回答by Samir Mangroliya
I had same error...Please Uncheck the offline work in Settings.
我有同样的错误...请在设置中取消选中离线工作。
File => Settings => Build, Execution, Deployment => Build Tools => Gradle => Offline Work
文件 => 设置 => 构建、执行、部署 => 构建工具 => Gradle => 离线工作
After Gradle Sync Finished, Please Restart Your Android Studio.
Gradle 同步完成后,请重新启动您的 Android Studio。
回答by MEGHA DOBARIYA
Please follow below steps :
请按照以下步骤操作:
1.Open Your project.
1.打开你的项目。
2.Go to the Left side of the Gradle button.
2.转到 Gradle 按钮的左侧。
3.Look at below image.
3.看下图。
4.Click button above image show.
4.单击图像显示上方的按钮。
5.if this type of view you are not in offline mode.
5.如果这种类型的视图你不是在离线模式。
6.Go to Build and rebucild the project.
6.转到Build并重新构建项目。
All above point is work for me.
以上所有点对我来说都是工作。
回答by touhid udoy
For mac, Uncheck Offline Work
from Preference -> Build, Execution, Deployment -> Build Tools -> Gradle -> Global Gradle Settings
对于Mac,取消Offline Work
从Preference -> Build, Execution, Deployment -> Build Tools -> Gradle -> Global Gradle Settings
tip: cmd
+,
to open Preference
via shortcut key
提示:cmd
+通过快捷键,
打开Preference
回答by Tony D
Since you mention you have a proxy connection I will tell you what worked for me: I went to properties (as friedrich mentioned) ensuring the Offline Work was unchecked. I opened up the gradle.properties file in the IDE and added my proxy settings. Here's a generic version:
既然你提到你有一个代理连接,我会告诉你什么对我有用:我去了属性(如弗里德里希提到的)确保离线工作没有被选中。我在 IDE 中打开了 gradle.properties 文件并添加了我的代理设置。这是一个通用版本:
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
Then at the top of the properties file in the IDE there was a "Try Again" link which I clicked. That did it.
然后在 IDE 中属性文件的顶部有一个“再试一次”链接,我点击了它。做到了。
回答by Akshay Vijay Jain
In my case I get the same error title could not resolve all dependencies for configuration
在我的情况下,我得到相同的错误标题无法解决配置的所有依赖项
However suberror said, it was due to a linting jar not loaded with its url given saying status 502 received, I ran the deployment command again, this time it succeeded.
然而子错误说,这是由于一个 linting jar 没有加载它的 url,给出状态 502 收到,我再次运行部署命令,这次它成功了。