该项目正在使用不受支持的Gradle版本 [英] The project is using an unsupported version of Gradle

查看:85
本文介绍了该项目正在使用不受支持的Gradle版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注Android Studio中的教程

I am following this tutorial in Android Studio.

尝试导入项目时,出现一个对话框,提示:

When trying to Import the project, I get a dialog saying:

"该项目正在使用不受支持的Gradle版本."请在项目的Gradle设置或项目的Gradle包装器(如果适用)中指向受支持的Gradle版本."

如果我通过声明选择 wrapper 方法,也会失败:"未找到ID为'com.android.application'的插件.

It also fails if I select the wrapper method by stating: "Plugin with id 'com.android.application' not found.

这是Parse的gradle的样子:

Here is what Parse's gradle looks like:

apply plugin: 'com.android.application'

repositories {
    mavenCentral() }

dependencies {
    compile 'com.parse.bolts:bolts-android:1.1.3'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar') }

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    } 
}

我的项目的Gradle:

My project's Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "id.goes.here"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    } }

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

推荐答案

您的项目中通常有两个build.gradles:

You generally have two build.gradles in your project:

  • 项目根目录中的顶级build.gradle,其中包含 buildscript {} allprojects {} 部分.这包含项目范围的配置.
  • 一个应用程序模块build.gradle(位于应用程序的模块文件夹中),其中包含android应用程序的配置.这包含 android {} 部分.
  • A top level build.gradle in your project's root that contains buildscript {} and allprojects {} sections. This contains the project-wide configuration.
  • An app module build.gradle (located in your app's module folder) that contains the configuration for your android application. This one contains the android {} section.

打开顶级build.gradle,然后查看Android Gradle插件版本(外观类似于 classpath'com.android.tools.build:gradle:1.0.0-rc3').

Open up your top level build.gradle, and look at the Android Gradle plugin version (it will look something like classpath 'com.android.tools.build:gradle:1.0.0-rc3').

如果插件的版本为0.13.0或更高版本,则需要确保您使用的是Gradle 2.1或更高版本.如果插件的版本低于0.14.4,则不能使用Gradle 2.2 +.

If the plugin is at version 0.13.0 or higher, you need to make sure you are using Gradle 2.1 or newer. If the plugin is below version 0.14.4, you cannot use Gradle 2.2+.

在继续之前,您需要确定您是使用本地gradle分发版还是包装器.为此,请转到文件">设置",然后搜索渐变".如果选择了使用本地Gradle分发",则可以将本地Gradle更新为受支持的版本,或切换为使用包装器.

Before going further, you need to find out whether you are using a local gradle distribution or the wrapper. To do so, go to File > Settings, then search for "Gradle." If "Use local Gradle distribution" is selected, either update your local Gradle to a supported version or switch to using the wrapper.

如果使用包装器,则Gradle版本的配置位于< your-project>/gradle/wrapper/gradle-wrapper.properties 下.该文件包含如下内容: distributionUrl = https \://services.gradle.org/distributions/gradle-2.2.1-all.zip.只需将最后的版本更改为受支持的版本.

If you are using the wrapper, the configuration for the Gradle version is located under <your-project>/gradle/wrapper/gradle-wrapper.properties. This file contains a line that will look something like this: distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip . Simply change the version at the end to a supported version.

如果您点击错误消息告诉您它不是受支持的版本,那么Studio通常会为您更新包装程序.

Studio typically will offer to update the wrapper for you if you click on the error telling you that it is not a supported version.

这篇关于该项目正在使用不受支持的Gradle版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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