【问题标题】:Android Studio 1.0RC4 Gradle build errorAndroid Studio 1.0RC4 Gradle 构建错误
【发布时间】:2015-02-06 02:29:50
【问题描述】:

我刚刚下载了 Android Studio 1.0RC4,我无法构建任何项目,甚至是新创建的项目。

我得到的错误是:

错误:无法使用 Gradle 分发版“https://services.gradle.org/distributions/gradle-2.2.1-all.zip”运行构建操作。

我能够从浏览器下载 zip,但它在 AS 上不起作用。这是我的 build.gradle 文件:

// 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:1.0.0-rc1'

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

allprojects {
    repositories {
        jcenter()
    }
}

模块构建文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "simple.com.car10"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Graddle-wrapper.properties

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

我尝试运行 graddle - 从 cmd 构建,但出现此错误:

FAILURE: Build failed with an exception.

* What went wrong:
Build file 'C:\Users\Giovanni\uild' does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

总时间:3.093 秒

JDK:1.8.0_05

当我再次点击尝试时,没有任何反应,我已经尝试卸载所有内容并再次安装,但没有成功。

有什么想法吗?谢谢。

【问题讨论】:

  • 这是通用的 Gradle 文件。用你的模块名称发布一个。
  • 使用 app graddle 编辑
  • 你能显示你的 gradle-wrapper.properties 文件吗?
  • 文件中没有什么奇怪的。您是否正确设置了 SDK 路径?你用的是什么JDK?
  • 用wrapper和jdk版本编辑,SDK设置正确。

标签: android android-studio android-gradle-plugin


【解决方案1】:

我终于搞定了,伙计们

我必须删除 'C:\Users\Username\' 中的 .gradle 文件夹,然后我以管理员权限打开 AS它又复活了!

谢谢大家。

【讨论】:

  • 对于*NIX用户,删除$HOME/.gradle下的目录,然后重启Android studio。
  • 如果你有 x64 位 Intelli J,那么你必须有 x64 位 java 并设置了 JAVA_HOME 并设置了 _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true 出于某种原因它与 ipv6 有问题。糟透了
  • 删除 .gradle one 中的缓存文件夹并以管理员权限重新启动 Android Studio 就足够了。无论如何,谢谢:)
  • Mac Yosemite 上同样的错误。已删除站点中的所有内容-多次重新安装。始终获取:请参阅 IDE 日志以获取更多详细信息(帮助 | 显示日志)日志显示:2016-04-11 18:40:45,569 [13180] 信息 - ls.idea.gradle.GradleSyncState - 与项目“我的应用程序”的 Gradle 同步'失败:无法使用指定的 Gradle 安装创建 Tooling API 实现的实例'/Applications/Android Studio.app/Contents/gradle/gradle-2.10'。
【解决方案2】:

您可能可以在 build.gradle 中删除 RC-1:

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

这是最近发生变化的清单

http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0

【讨论】:

    【解决方案3】:

    对于 64 位 Windows 7,除了删除 .gradle 并以管理员身份启动 Android Studio 之外,我还必须下载 jdk7 64 位。我还将 JAVA_HOME 设置为 64 位 JDK,并将 JAVA_OPTIONS 设置为 -Djava.net.preferIPv4Stack=true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-13
      • 2016-08-05
      • 2017-03-25
      • 2016-01-19
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      相关资源
      最近更新 更多