No cached version of com.android.tools.build:gradl

2019-01-03 10:10发布

I got a an error message while building a new Hello World project in Android Studio.

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 Gradle version : 0.9.1

I'm using a proxy connection to Internet.

Please can anyone give a solution to this problem. I have searched internet for above problem, but couldn't get any proper solution to this issue.

5条回答
别忘想泡老子
2楼-- · 2019-01-03 10:45

Had the same error after updating Android Studio today. For me, it wasn't a matter of proxy settings:

  1. 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

  2. Resync the project, for example by restarting the Android Studio

  3. Once synced, you can check the option again to work offline.

(Only tested in Gradle version 0.11... and Android Studio version 0.6.0 Preview)

EDIT : Added paths for different versions/platforms (as mentioned by John Ballinger and The_Martian). Not yet verified.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-03 10:55

Just happened to me after upgrading to Android Studio 3.1. The Offline Work checkbox was unchecked, so no luck there.

I went to Settings > Build, Execution, Deployment > Compiler and the Command-line Options textfield contained --offline, so I just deleted that and everything worked.

查看更多
该账号已被封号
4楼-- · 2019-01-03 10:55

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:

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.

查看更多
趁早两清
5楼-- · 2019-01-03 10:59

I had same error...Please Uncheck the offline work in Settings.

File => Settings => Build, Execution, Deployment => Build Tools => Gradle => Offline Work

After Gradle Sync Finished, Please Restart Your Android Studio.

查看更多
地球回转人心会变
6楼-- · 2019-01-03 11:04

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.

查看更多
登录 后发表回答