【问题标题】:Could not resolve all dependencies for configuration ':classpath' on Android Studio无法解析 Android Studio 上配置“:classpath”的所有依赖项
【发布时间】:2016-07-30 04:36:20
【问题描述】:

我在打开 Android Studio 时遇到此错误

我以前从未遇到过这个错误。我已经尝试清理并重新同步gradle,我已经更新了 SDK Manager 中的所有包,

我已经重启了我的 Android Studio,

我已经以管理员身份运行了,

我也尝试过构建一个新项目,但这个错误不会消失。

请帮我解决这个问题。

Error:Failed to create parent directory 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4' when creating directory 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401'

[更新]

在我尝试重建我的项目后,我收到了一个类似这样的新错误。

Error:A problem occurred configuring root project 'BPSGoSurvey'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve commons-logging:commons-logging:1.1.1.
     Required by:
         :BPSGoSurvey:unspecified > com.android.tools.build:gradle:1.3.0 > com.android.tools.build:gradle-core:1.3.0 > com.android.tools.build:builder:1.3.0 > com.android.tools:sdklib:24.3.0 > org.apache.httpcomponents:httpclient:4.1.1
         :BPSGoSurvey:unspecified > com.android.tools.build:gradle:1.3.0 > com.android.tools.build:gradle-core:1.3.0 > com.android.tools.build:builder:1.3.0 > com.android.tools:sdklib:24.3.0 > org.apache.httpcomponents:httpmime:4.1
      > Could not resolve commons-logging:commons-logging:1.1.1.
         > Could not parse POM file:/E:/Android%20Studio/gradle/m2repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
            > Could not resolve org.apache.commons:commons-parent:5.
               > Could not resolve org.apache.commons:commons-parent:5.
                  > Could not parse POM file:/E:/Android%20Studio/gradle/m2repository/org/apache/commons/commons-parent/5/commons-parent-5.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download8245895784892794258bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
               > Could not resolve org.apache.commons:commons-parent:5.
                  > Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/5/commons-parent-5.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download3502880229047415896bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
      > Could not resolve commons-logging:commons-logging:1.1.1.
         > Could not parse POM https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
            > Could not resolve org.apache.commons:commons-parent:5.
               > Could not resolve org.apache.commons:commons-parent:5.
                  > Could not parse POM file:/E:/Android%20Studio/gradle/m2repository/org/apache/commons/commons-parent/5/commons-parent-5.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download6416635460030578050bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
               > Could not resolve org.apache.commons:commons-parent:5.
                  > Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/5/commons-parent-5.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download916061549622655000bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
   > Could not resolve commons-codec:commons-codec:1.4.
     Required by:
         :BPSGoSurvey:unspecified > com.android.tools.build:gradle:1.3.0 > com.android.tools.build:gradle-core:1.3.0 > com.android.tools.build:builder:1.3.0 > com.android.tools:sdklib:24.3.0 > org.apache.httpcomponents:httpclient:4.1.1
      > Could not resolve commons-codec:commons-codec:1.4.
         > Could not parse POM file:/E:/Android%20Studio/gradle/m2repository/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
            > Could not resolve org.apache.commons:commons-parent:11.
               > Could not resolve org.apache.commons:commons-parent:11.
                  > Could not parse POM file:/E:/Android%20Studio/gradle/m2repository/org/apache/commons/commons-parent/11/commons-parent-11.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download8269455495978527180bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
               > Could not resolve org.apache.commons:commons-parent:11.
                  > Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/11/commons-parent-11.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download3692548803835443828bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
      > Could not resolve commons-codec:commons-codec:1.4.
         > Could not parse POM https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
            > Could not resolve org.apache.commons:commons-parent:11.
               > Could not resolve org.apache.commons:commons-parent:11.
                  > Could not parse POM file:/E:/Android%20Studio/gradle/m2repository/org/apache/commons/commons-parent/11/commons-parent-11.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download5076305514553905674bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 
               > Could not resolve org.apache.commons:commons-parent:11.
                  > Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/11/commons-parent-11.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not get resource 'https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom'.
                              > Failed to move file 'C:\Users\User\AppData\Local\Temp\gradle_download1507005468069947828bin' into filestore at 'C:\Users\User\.gradle\caches\modules-2\files-2.1\org.apache\apache\4\602b647986c1d24301bc3d70e5923696bc7f1401\apache-4.pom' 

【问题讨论】:

  • 尝试删除 modules-2 文件夹,它是 gradle 临时保存从 repos 中获取的文件的地方,并仔细检查您的 build.gradle 文件中是否有任何异常
  • @quidproquo 我试过你的建议,但没用

标签: android android-studio


【解决方案1】:

由于它是一个 gradle 缓存目录,请尝试强制删除它(或其父目录)。某些其他进程可能已锁定该目录,不允许 Studio 访问它。删除后,关闭所有与 Android Studio 关联的进程(adb、studio.exe、java.exe 等)。然后尝试重新启动 Studio。

【讨论】:

  • 我已经删除了缓存目录,但是还是不行:(
  • 您是否也尝试过删除/.gradle/ 目录?
  • 我不能删除gradle目录,它说是因为目录不是空的
  • 你应该可以删除它。尝试安全模式/命令提示符/重启/等。取决于您的操作系统。
  • 请看看我更新的问题。尝试重建项目时出现新错误。该错误与旧错误相同吗?
猜你喜欢
  • 2014-11-17
  • 2020-12-20
  • 2016-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-26
  • 2018-03-31
相关资源
最近更新 更多