更新到Android Studio 2.3后出现Gradle错误 [英] Gradle error after updating to Android Studio 2.3

查看:139
本文介绍了更新到Android Studio 2.3后出现Gradle错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gradle构建失败,并显示消息

The gradle build is failing with the message

 Error:Could not create parent directory for lock file C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1-all.zip.lck

这是我的build.gradle(Project)

This is my build.gradle(Project)

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

 buildscript {
   repositories {
    jcenter()
}
    dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
 }

allprojects {
  repositories {
    jcenter()
  }
}

  task clean(type: Delete) {
    delete rootProject.buildDir
}

所有项目在更新后都显示相同的错误.

All projects show the same error after the update.

推荐答案

我也遇到了类似的错误,下面的更改完成了工作.

I was also facing the similar error, below changes did the job.

问题是Android Studio 2,3,它的默认gradle版本是3.3.

The issue was Android Studio 2,3 and it's default gradle version is 3.3.

在Android Studio弹出消息进行更新并将Gradle插件版本更新为2.3.0后,我不小心将SDK生成工具更新为最新的25.0 .0,为此

I accidentally updated SDK build tools to latest one 25.0 .0, after Android Studio popped up message to update and Gradle plugin version to 2.3.0 for which required gradle version is 3.3+.

我进行了以下更改以解决此问题:

I did the below changes to fix the issue:

  1. 安装了较旧的SDK生成工具19.1.0,以使用以前的Gradle 版本
  2. 文件>项目结构>项目>并将gradle版本更改为2.3.0
  3. 将build.gradle(Project:app_name)>类路径'com.android.tools.build:gradle:3.3.0'更改为 'com.android.tools.build:gradle:2.1.2'
  1. Installed older SDK build tools 19.1.0 to use previous Gradle versions
  2. File> Project Structure > Project > And change the gradle version to 2.3.0
  3. Changed build.gradle(Project: app_name) > classpath 'com.android.tools.build:gradle:3.3.0' to 'com.android.tools.build:gradle:2.1.2'

最后,执行使缓存无效/重新启动或同步".

Finally, do Invalidate Caches / Restart or Sync.

似乎最好不要使用3.3.

It seems like it's better not to use 3.3 yet. Source & Credits

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

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