2

Updated Android studio.

Downloaded Gradle. Changed Gradle folder in PC's environmental settings.

In computer, gradle -version returns Gradle 4.4.1. Gradle Settings in Android Studio and Environment

In Android Studio, returns Gradle 3.5

Smart Android IDE refuses to recognise gradle and I can't compile.

It even gives the wrong error message

Minimum supported Gradle version is 4.1. Current version is 3.5. If using the gradle wrapper, try editing the distributionUrl in C:\xxxxxx\gradle\wrapper\gradle-wrapper.properties to gradle-4.1-all.zip

enter image description here

Android Studio Terminal refuses to get gradle 4.4.1

I have tried restarting, invalidate and restart. Nothing works.

How to fix it?

theAnonymous
  • 1,701
  • 2
  • 28
  • 62

4 Answers4

2

You need to go to File->Settings->Build,Execution,Deployment->Gradle

Then tick User local gradle distribution and set the path to your local gradle

Eselfar
  • 3,759
  • 3
  • 23
  • 43
  • Tried it before posting here. Does not work. Still 3.5. – theAnonymous Mar 21 '18 at 10:19
  • In File->Project Structure->Project what is the Gradle version defined? – Eselfar Mar 21 '18 at 10:23
  • Defined as `4.4.1`. – theAnonymous Mar 21 '18 at 10:23
  • 1
    Try to remove gradle-wrapper.properties together with what's mentioned above. You don't need it as you're using the local version and not the wrapper. But because of that you can't specify the gradle version (it's gonna use whatever is the local one). I think that why AS use the wrapper as default, to make sure the gradle version is consistent if you change config/there is more than one dev on the project. Alternatively you can still use the wrapper and not the local version and set gradle-wrapper to 4.4.1 – Eselfar Mar 21 '18 at 10:51
1

Fixed it by restarting the computer.

Restarting the IDE is not good enough. After restarting computer and going into Android Studio's terminal, typing in gradle -version shows the correct version. That's when I know it'd work. Sure enough, gradle commands now work.

Answered this just to show how genius the IDE written by geniuses is.

theAnonymous
  • 1,701
  • 2
  • 28
  • 62
0

I check android studio offical web, android studio IDE now support version just to gradle-4.1. I think you can go to gradle-wrapper.properties, and change to distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

or

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

, maybe it can solve the problem.

Reference site: https://developer.android.com/studio/releases/gradle-plugin.html

Sean Lee
  • 73
  • 1
  • 2
  • 9
  • this is already mentioned by OP. this suggestion doesnt make sense. – Rohit5k2 Mar 21 '18 at 10:25
  • Changing to `4.1` still causes the same error, and in Android Studio's terminal, it's still 3.5, even if I restart. – theAnonymous Mar 21 '18 at 10:37
  • Sorry for my last wrong post. Have you try this way, it seem like similar problem... [link](https://stackoverflow.com/a/43077785/8355528) – Sean Lee Mar 21 '18 at 10:52
0

I faced this problem and i had fixed it. first goto https://services.gradle.org/distributions/gradle-4.10.1-all.zip and download it locally. Goto File->Settings->Build,Execution,Deployment->Gradle and select "Use local gradle" and set local gradle path that you downloaded just.

gradle path

swiftBoy
  • 35,607
  • 26
  • 136
  • 135