简体   繁体   中英

Android Studio installation doesn't work with gradle

I am absolute beginner with Android Studio (especially Gradle) and having big trouble getting Android Studio to work. I downloaded and installed the most recent version of Android Studio (0.8.0). I have set the JDK_HOME variable. However, after I create a new project, I always receive the following message:

Error:Unknown host 'jcenter.bintray.com'. 
Enable Gradle 'offline mode' and sync project.
Learn about configuring HTTP proxies in Gradle

If I try to compile the project, I get the following message dialog:

在此输入图像描述

After reading a post, I manually downloaded the Gradle binaries (latest, 2.0), extracted it onto the local drive, went to Settings and set the Gradle path to the respective directory using the following:

在此输入图像描述

I also tweaked the build.gradle file under the project to point to the latest Gradle 2.0 version. However, now I get the following error message:

Error:A problem occurred configuring root project 'HelloAndroidStudio'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:2.0.+.
Required by:
  :HelloAndroidStudio:unspecified
    Failed to list versions for com.android.tools.build:gradle.
    Unable to load Maven meta-data from     http://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml.
    Could not GET 'http://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml'.
    jcenter.bintray.com

Please can someone help. Being my first time with Gradle, I have been trying for so many days without any clue to the problem. Thanks.

Change the Gradle version to lower ones and restart the Android Studio, you may get it.

Add this in build.gradle classpath 'com.android.tools.build:gradle:1.1.0'

在外观和行为 - >系统设置 - > http代理下设置http_proxy解决了这个问题

Change to the latest classpath in the dependencies. For AS 1.5.1 I will do like this :

buildscript {
repositories {
    jcenter()
  }

dependencies {
    **classpath 'com.android.tools.build:gradle:1.5.0'**
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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