警告:需要Gradle版本2.10。目前的版本是2.4

时间:2016-07-18 15:36:35

标签: android android-studio gradle android-gradle

我尝试使用GCM实施Android推送通知。以下是我得到的错误

最新错误

  Warning:Gradle version 2.10 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in C:\Users\seng\AndroidStudioProjects\ChatApp\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip

Can't start Git: git.exe
            Probably the path to Git executable is not valid. Fix it. (show balloon)

应用程序级build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'

    //This line is added
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
}

//This line is added
apply plugin: 'com.google.gms.google-services'

项目级别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.3.0'

        //These two lines are added
        classpath 'com.google.gms:google-services:1.5.0-beta2'
        classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
        // 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
}

gradle-wrapper.properties

#Mon Jul 18 23:51:22 SGT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
https\://services.gradle.org/distributions/gradle-2.10-all.zip=

2 个答案:

答案 0 :(得分:1)

您需要修改gradle/wrapper/gradle-wrapper.properties

distributionUrl更改为https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

答案 1 :(得分:0)

  1. 将gradle-wrapper.properties中的distributionUrl更新为
  2. https\://services.gradle.org/distributions/gradle-2.10-all.zip

    1. 您还可以将root build.gradle中的gradle构建工具以及app level build.gradle文件更新到最新版本。就我而言,它是classpath 'com.android.tools.build:gradle:2.1.2'