【Android studio】No cached version .. available for offline mode - Could not resolve all dependencies

一、今天解决的一个问题

  • 报错如下:「如果我的方案对你有用,记得点赞哦」

  • 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
    
  • 这里只给了 gradle 包丢失的情况,还有其他包丢失

二、解决方案

  • 解决原理是一样的,但根据 as 的版本不同有所区分
  • 下面分 **「旧版 AS」「最新 3.6.+ AS」**两部分讲解解决方案

2.1 旧版 AS

2.1.1 古董版 AS 如 Android Studio 0.6.0:
  • 打开设置:File->Settings->Gradle->Global Gradle Settings
  • 取消勾选:“Offline work”
2.1.2 在 OSX 中
  • 打开设置:Preferences->Gradle->Global Gradle Setting

  • 取消勾选:“Offline work”

2.1.3 较新版本的 AS (非 3.6.+)
  • 打开设置:File->Settings->Build, Execution, Deployment->Build tools->Gradle
  • 取消勾选:“Offline work”

2.2 最新 3.6.+ 方案

  • 打开路径 View>Tool Windows>Gradle

  • 弹出如下界面:

  • 将这个选定状态的按钮,取消勾选

2.3 点击 sync 重新导入

  • 大成了
  • 分享不易,如果该方案对你有用,请帮忙点赞哦

2.4 如果还不行

  • 大概率是 Proxy 的问题,路径如下「MAC - Preferences」&「Windows - setting」

  • 大成,如果没有的话只能手动下载

总结

  • 分享不易,如果回答对你有帮助,你的点赞,是我分享的最大动力!

猜你喜欢

转载自blog.csdn.net/qq_43377749/article/details/106074189