0

I am running Fedora 31 and Gradle 4.4.1 is installed on the machine. I have my Android project under Android Studio 3.5.2. When I run the command "gradle wrapper" in order to generate "gradlew" wrapper script, I get the following error:

Minimum supported Gradle version is 5.4.1. Current version is 4.4.1. If using the gradle wrapper, try editing the distributionUrl in /home/danesh/open/code/zink/zink_android/gradle/wrapper/gradle-wrapper.properties to gradle-5.4.1-all.zip

I also have "gradle-5.4.1-all.zip" in the file "gradle-wrapper.properties"- Here comes the tree structure of my gradle directory under my project root directory:

├── gradle

│   └── wrapper

│   ├── build

│   │   ├── libs

│   │   │   └── wrapper.jar

│   │   └── tmp

│   │   └── jar

│   │   └── MANIFEST.MF

│   ├── build.gradle

│   ├── gradle

│   │   └── wrapper

│   │   ├── gradle-wrapper.jar

│   │   └── gradle-wrapper.properties

│   ├── gradlew

│   ├── gradlew.bat

│   ├── gradle-wrapper.jar

│   ├── gradle-wrapper.properties

│   └── settings.gradle

I have tried to execute the command "gradle wrapper" under project directory and got the aforementioned error. I also executed same command under "gradle/wrapper" and the file "gradlew" was actually generated but the script does nothing when I run for instance "./gradlew build" and just shows the message that "1 file is up-to-date" and nothing is generated.

Does anybody know how can I generate valid gradle wrapper file so I will be able to build and run my unit tests and download all dependencies using command line and gradle wrapper script?

I also would like to know how can I upgrade my gradle to latest (it should be version 6 up to November 2019)? It seems the official repos are not updated to the latest version of gradle.

Thanks in advance,

D.

Dan
  • 126
  • 1
  • 14
  • Tried this: https://stackoverflow.com/a/35272475/5192105? – Sachin Bahukhandi Nov 17 '19 at 17:47
  • @SachinBahukhandi Yes I have tried that. In Android Studio the plugin version is set to 3.5.2 and the Greadle version to 5.4.1 but when I run "gradle --version" in command line I get the 4.4.1 for gradle version. This is weird too since apparently Android Studio is using newer version of gradle that I cannot execute using command line. – Dan Nov 17 '19 at 18:42
  • Try invalidating your cache and try again. Also if the problem persists use a local gradle dist by downloading from the official website. – Sachin Bahukhandi Nov 18 '19 at 14:20

1 Answers1

1

It's possible to upgrade gradle per project using the gradle wrapper. Assuming you've previously initiated your project with gradle init, make sure that you are using java 8. As you'll get an exception with java 11 and higher.

update-alternatives --config java

Then update gradle locally using the wrapper:

./gradlew wrapper --gradle-version=6.2.2 --distribution-type=bin

And verify that your project now uses 6.2.2:

$ ./gradlew           

> Task :help

Welcome to Gradle 6.2.2.

To run a build, run gradlew <task> ...
...
D. Asyl
  • 31
  • 1
  • 5
  • in IntelIJ IDEA 2019.3.3 it doesn't help, although when `./gradlew` is run it shows brand new version installed, but when `gradle --version` is run it shows still the **old (4.4.1) version** – NikolaS Jul 30 '20 at 11:20
  • Just restarted my IDE and it works. BTW, I've also upgraded ti via SDKMan (not sure that also had positive impact on it to work). Thanks for this suggestion though. :) – NikolaS Jul 30 '20 at 11:37