How to get Gradle 1.9 in android-studio 0.3.6 runn

2019-05-16 16:38发布

问题:

I just spend some time and failed trying to migrate an existing android studio project from gradle 1.8 to gradle 1.9 final ( which was released yesterday 19th Nov ).

I read most of the other gradle related posts here but none worked for me. here a list of what I've tried so far:

  • ./gradle/wrapper/gradle-wrapper.properties changed distributionUrl to gradle-1.9-all.zip
  • Rebuild Project
  • in android-studio: Tools -> Android -> Synch Project with Gradle Files
  • running command gradle wrapper in project dir to update the wrapper
  • -

build.gradle file

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
    }
}

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

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.0'
}

all ended with the "need gradle 1.8, change your gradle-wrapper.properties to gradle-1.8-all.zip" error message.

回答1:

Gradle 1.9 isn't supported with the Android plugin 0.6.3; it requires 1.8. The plugin uses internal Gradle APIs and is tied to specific Gradle versions to ensure it works. This limitation will be lifted in the future, but will require some new features in Gradle.

The next version of the plugin will support Gradle 1.9.

EDIT:

Android Studio 0.4.0 and Android Gradle plugin 0.7.0 have been released; these support Gradle 1.9. At the time of writing, Gradle 1.10 is current, but is not supported yet in v0.7.0 of the plugin.



回答2:

You could try this:

Close your Project and try to open your project, but instead of choosing the root folder of your project choose your settings.gradle file.

AS will ask you if you want to open this project -> click "Yes". Than a window appears "Import Project from Gradle". Make sure that "Use default gradle wrapper" is selected.

This helped me after upgrading AS to 0.3.1, since this version you need gradle 1.8.