简体   繁体   English

在Gradle上创建新项目时,Android Studio陷入困境:配置项目或Gradle:Resolve Dependencies':classpath:'

[英]Android Studio stuck when creating new Project on Gradle: Configure Project or Gradle: Resolve Dependencies ':classpath:'

Using the new project wizard to create a new Android application, The IDE gets stuck before I can even see the Code files. 使用新项目向导创建一个新的Android应用程序,在我甚至看不到代码文件之前,IDE就会卡住。 After trying to create many types of projects, It tells me that it is building and the IDE only shows a Loading box that says either: 尝试创建多种类型的项目后,它告诉我它正在构建,IDE只显示一个Loading框,其中显示:

Gradle: Configure Project 

or 要么

Gradle: Resolve Dependencies ':classpath:'

I went out to lunch and when I came back I saw: 我出去吃午饭,当我回来时,我看到:

Error:Could not HEAD ' http://jcenter.bintray.com/com/android/tools/build/builder-model/0.12.1/builder-model-0.12.1.jar '. 错误:无法加入' http://jcenter.bintray.com/com/android/tools/build/builder-model/0.12.1/builder-model-0.12.1.jar '。 Received status code 500 from server: Internal Server Error Enable Gradle 'offline mode' and sync project 从服务器收到状态码500:内部服务器错误启用Gradle'离线模式'和同步项目

Bintray has experienced momentary timeouts yesterday due to a change to one of the cluster nodes in Dallas. 由于改变了达拉斯的一个集群节点,Bintray昨天经历了短暂的超时。 It looks like you've happened to hit that exact node at that exact time. 看起来你碰巧在那个确切的时间点击了那个确切的节点。

The issue has been sorted out after a couple of minutes, so there is no real need to change anything on your side. 问题已在几分钟后解决,所以没有必要改变你身边的任何事情。

Actually, keeping jcenter() in your script is preferable since it's a super-set of Maven Central. 实际上,将jcenter()保留在脚本中是比较好的,因为它是Maven Central的超级集合。

In order to solve it, I went to File -> Project Structure -> Project and changed: 为了解决这个问题,我去了File -> Project Structure -> Project并更改了:

Android Plugin Repository and Default Plugin Repository from their default values of Android插件存储库和默认插件存储库的默认值为

jCenter()

to

mavenCentral

I had a similar problem and was able to use both repositories by including them both in my build.gradle in my android directory: 我有一个类似的问题,并能够通过将它们都build.gradle在我的android目录中的build.gradle中来使用这两个存储库:

allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}

This is an adjustment to @MHDante's answer - instead of replacing one with the other, you can use both! 这是对@ MHDante答案的调整 - 你可以同时使用两者来代替另一个!

I was heaving the same/similar problem: 我正在解决相同/类似的问题:

Error:A problem occurred configuring root project 'X'. 错误:配置根项目“X”时出现问题。 Could not resolve all dependencies for configuration ':classpath'. 无法解析配置':classpath'的所有依赖项。 Could not resolve com.android.tools.build:gradle:0.12.+. 无法解决com.android.tools.build:gradle:0.12.+。 Required by: :X:unspecified Failed to list versions for com.android.tools.build:gradle. 要求:: X:未指定无法列出com.android.tools.build:gradle的版本。 Could not list versions using M2 pattern ' http://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]- revision.[ext]'. 无法使用M2模式“ http://jcenter.bintray.com/ [organisation]/[module]/[revision]/[artifact]- revision。[ext]'列出版本。 Could not GET ' http://jcenter.bintray.com/com/android/tools/build/gradle/ '. 无法获得' http://jcenter.bintray.com/com/android/tools/build/gradle/ '。 Received status code 401 from server: Authorization Required 从服务器收到状态码401:需要授权

But I resolved it by calling synchroise and then rebuilding the project. 但我通过调用同步然后重建项目来解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM