刷新gradle时Android Studio 1.3.2错误 [英] Android Studio 1.3.2 error when refreshing gradle

查看:30
本文介绍了刷新gradle时Android Studio 1.3.2错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Eclipse 生成了 build.gradle 文件并将其导入到 android studio.

然而,它在刷新gradle"后返回错误:

<块引用>

Gradle 同步失败:找不到 com.android.tools.build:gradle-1.12

这是classpath :

classpath 'com.android.tools.build:gradle-1.12'

这是我的 gradle 目录中的内容:

C:\Users\user\.gradle\wrapper\dists\gradle-1.12-all

这就是我在项目根目录中的 gradle-wrapper.properties 文件中的内容:

distributionBase=GRADLE_USER_HOME分布路径=包装器/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-1.12-all.zip

这是错误日志:

java.io.FileNotFoundException:无法找到 Gradle 主目录的路径在 com.android.tools.idea.gradle.util.GradleUtil.stopAllGradleDaemons(GradleUtil.java:462)

我该怎么办?

我尝试使用不同的互联网连接,有/没有代理.

感谢您的时间.

解决方案

不要混淆 Android 和 gradle 的 gradle-plugin.
它们是不同的.您可以在此处

使用 gradle 文件中的 classpath,您可以为 Gradle 设置 android 插件的版本.

使用以下方法更改您的classpath:

classpath 'com.android.tools.build:gradle:1.3.1'

代替:

classpath 'com.android.tools.build:gradle-1.12'

gradle-wrapper.properties 文件中,您可以设置 Gradle 的版本.例如2.4版本.

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

I generated build.gradle file from eclipse and import it to android studio.

However, it returns error after "refreshing gradle" :

Gradle sync failed: Could not find com.android.tools.build:gradle-1.12

This is the classpath :

classpath 'com.android.tools.build:gradle-1.12'

This is what i have in my gradle directory :

C:\Users\user\.gradle\wrapper\dists\gradle-1.12-all

And this is what i have in gradle-wrapper.properties file in my project's root :

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-all.zip

This is the error log :

java.io.FileNotFoundException: Unable to find path to Gradle home directory
    at com.android.tools.idea.gradle.util.GradleUtil.stopAllGradleDaemons(GradleUtil.java:462)

What should i do?

I have tried to use different internet connections, with/without proxy.

Thanks for your time.

解决方案

Don't confuse the gradle-plugin for Android and gradle.
They are different. You can find more info about the android plugin here

With the classpath inside your gradle files, you set the version of the android plugin for Gradle.

Change your classpath using:

classpath 'com.android.tools.build:gradle:1.3.1'

instead of:

classpath 'com.android.tools.build:gradle-1.12'

In the gradle-wrapper.properties file you set the version of the Gradle. For example the 2.4 version.

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

这篇关于刷新gradle时Android Studio 1.3.2错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆