Gradle同步失败:升级Android插件到版本“2.0.0”失败。

7

我最近更新了Android Studio到2.0版本。我正在参加一门兼职课程,并且必须使用提供的项目工作。当gradle尝试构建项目时,弹出了一个对话框要求我更新Android Studio gradle插件。当我点击更新时,标题中的错误出现了。

我的gradle文件如下:

Gradle Wrapper:

#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个回答

5
  1. Since you're using compileSdkVersion = 23, you need to use support libraries of version starting with 23 as well. That's com.android.support:design:23.3.0 in your case. It may be unrelated to the issue at hand but it will save you runtime errors later so fix it ASAP.

  2. Your gradle distribution is too old for Android build plugin. Use this in your gradle/gradle-wrapper.properties file:

    distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
    
  3. Newest build tools are "23.0.2". Update the value in your modules' build.gradle files.

  4. Google Play services plugin must be of the same version as Android build plugin. At least it had to be in beta stages and I imagine the major version has to correspond in any case. That's in your project build.gradle:

    classpath 'com.google.gms:google-services:2.0.0'
    
  5. While at it the Android build plugin is missing in there altogether!

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

可选项

  1. Your apt plugin is old. Newest version is 1.8.

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    
  2. Your OkHttp library is old. Newest versions are 2.7.5 or 3.2.0.

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接