android - Gradle 同步失败 : Failed to update Android plugin to version '2.0.0'

标签 android android-studio android-gradle-plugin gradle-plugin android-studio-2.0

我最近将 Android Studio 更新到了 2.0。我正在参加兼职类(class),我必须从事所提供的项目。当 gradle 尝试构建项目时,会弹出一个对话框,要求我更新 android studio gradle 插件。当我点击更新时,出现标题中的错误。

我的gradle文件如下:

渐变包装器:

#Wed Sep 30 11:56:02 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2-bin.zip

模块 Gradle :

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.1"

  defaultConfig {
    applicationId "com.example.sam_chordas.stockhawk"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

repositories {
  maven { url "https://jitpack.io" }
}

dependencies {

  compile 'com.google.android.gms:play-services-gcm:8.4.0'
  compile 'com.squareup.okhttp:okhttp:2.5.0'
  apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
  compile 'net.simonvt.schematic:schematic:0.6.3'
  compile 'com.melnykov:floatingactionbutton:1.2.0'
  compile 'com.android.support:design:23.1.1'
  compile('com.github.afollestad.material-dialogs:core:0.8.5.7@aar') {
    transitive = true
  }
}

项目 Gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
  repositories {
    jcenter()
    mavenCentral()
  }
  dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
    classpath 'com.google.gms:google-services:1.4.0-beta3'


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

allprojects {
  repositories {
    jcenter()
  }
}

我无法处理该项目,因为我无法构建它。如果有人遇到过这样的问题并解决了它,我将非常感谢您的帮助,因为我浪费了很多时间。我应该提一下,这是一台 Windows 7 机器。

谢谢

最佳答案

  1. 由于您使用的是 compileSdkVersion = 23,因此您还需要使用以 23 开头的版本的支持库。那是 com.android.support:design:23.3.0 在你的情况下。它可能与手头的问题无关,但它会在以后为您避免运行时错误,因此请尽快修复它。

  2. 您的 gradle 发行版对于 Android 构建插件来说太旧了。在您的 gradle/gradle-wrapper.properties 文件中使用它:

    distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
    
  3. 最新的构建工具是 “23.0.2”。更新模块的 build.gradle 文件中的值。

  4. Google Play 服务插件的版本必须与 Android 构建插件的版本相同。至少它必须处于测试阶段,而且我想主要版本在任何情况下都必须对应。那在你的项目 build.gradle 中:

    classpath 'com.google.gms:google-services:2.0.0'
    
  5. 虽然 Android build 插件完全没有!

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

可选

  1. 您的 apt 插件太旧了。最新版本是 1.8。

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    
  2. 您的 OkHttp 库很旧。最新版本为 2.7.5 或 3.2.0。

    compile 'com.squareup.okhttp:okhttp:2.7.5'
    

关于android - Gradle 同步失败 : Failed to update Android plugin to version '2.0.0' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36666080/

相关文章:

android - 在操作栏上搜索不会调用搜索 Activity

java - Samsung Galaxy Tab S 无法从 "Download"目录获取 listFiles

java - E/FirebaseInstanceId : Token retrieval failed: AUTHENTICATION_FAILED Android studio

android - 使用 google play 服务自动将 android apk 推送到 google play

android - 免安装应用的 Firebase 支持库依赖冲突

android - Intent.FLAG_ACTIVITY_CLEAR_TOP 在 Android 中不起作用

android - 天气 api 的 JSON 日期解析

android - android 上的 opengl es 颜色选择不闪烁

android - 应用程序声明了从配置 'compile' 到配置 'default' 的依赖关系,该依赖关系未在项目的描述符中声明

Android Studio 在构建时出现错误 "Could not download bundletool.jar"