2

Updated Android studio 2.2.0, it asked to update project setting "gradle 2.2" and I did but now build is not getting generated when I am running my application. Firstly, it was showing me lint errors and I fixed those. Now gradle console shows build successful but apk not getting generated in Output > apk folder as it usually do.

  • I followed "Minimum supported Gradle version is 2.14.1. Current version is 2.10." error link as well but no luck. I ran 'gradle assemble --stacktrace' and got this error:

    Caused by: org.gradle.api.GradleException: Minimum supported Gradle version is 2.14.1. Current version is 2.14. If using the gradle wrapper, try editing the distributionUrl in /Users/path to project/gradle/wrapper/gradle-wrapper.properties to gradle-2.14.1-all.zip

My gradle-wrapper.properties :

'distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip'

Do someone face similar problem? Any solution will be highly appreciable.


Gradle Console

Community
  • 1
  • 1
Sumit T
  • 1,273
  • 2
  • 17
  • 32
  • If you literally ran `gradle assemble --stacktrace`, that would be using the copy of Gradle installed on your development machine, not the Gradle Wrapper that Android Studio uses. You would need to upgrade your Gradle to 2.14.1 or higher. – CommonsWare Sep 20 '16 at 22:34
  • @CommonsWare : I followed https://developer.android.com/studio/releases/gradle-plugin.html , updated my build.gradle file & also updated gradle.wrapper.properties (Which I shared above). Where else do I need to change gradle version? – Sumit T Sep 20 '16 at 22:38

2 Answers2

2

In your root/build.gradle use: (gradle-plugin for android)

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

In the gradle-wrapper.properties file use: (gradle)

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip'

Also go to File > Settings > Builds,Execution,Deployment > Build Tools > Gradle and set Use default gradle wrapper

enter image description here

In this way you are sure that you will use the gradle wrapper (it means that you will use the gradlew command instead of gradle).

If you are running gradle assemble --stacktrace manually you are using the gradle distribution instead of the gradle wrapper.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • I did all these setting already, it's weird but still have the same problem only for one of my project, might be due to some libraries implemented into it. These settings worked for sample project I created. – Sumit T Sep 21 '16 at 18:57
1

This can be a weird problem to dig out of. Your project will no longer sync correctly which means you can't run the wrapper update task due to the project failing to get past the configuration phase of the gradle build.

You have two options, the first option:

Edit your rootProject build.gradle file to use an older version of the android gradle plugin. 2.1.3 is likely the correct choice here.

Following that you can run the following gradle command from the root directory of your project.

./gradlew wrapper --gradle-version=2.14.1

Once you have done that go and roll the android gradle plugin version back up to 2.2.0 and attempt to sync.

The second option is to update your local installed version of gradle to 2.14.1 or higher and then invoke

gradle wrapper --gradle-version=2.14.1

Then attempt to sync.

Once you are back into a working state I recommend you add the following task to your root level build.gradle file to make the wrapper task configuration built into your build script

task wrapper(type: Wrapper) {
    gradleVersion = '3.1' //or whatever version you like
    distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}

This makes it so your wrapper task will target the -all version instead of the -bin version which android studio will nag you to do after the fact if you don't have the configuration set like this

TrevJonez
  • 949
  • 8
  • 12
  • _I am getting below mentioned error while invoking 'gradle wrapper --gradle-version=2.14.1' _

    *What went wrong: A problem occurred evaluating project ':xyzLib'. > Failed to apply plugin [id 'com.android.library'] > Minimum supported Gradle version is 2.14.1. Current version is 2.14. If using the gradle wrapper, try editing the distributionUrl in /path to project/gradle/wrapper/gradle-wrapper.properties to gradle-2.14.1-all.zip*
    – Sumit T Sep 21 '16 at 20:23
  • Did you downgrade the plugin, update gradle wrapper, then upgrade plugin? be sure you are understanding that `./gradlew` and `gradle` commands are two different things. – TrevJonez Sep 22 '16 at 02:21