Get the most recent version (binaries are enough) on gradle's website:
https://gradle.org/
Extract it to :~/.gradle/wrapper/dists
Then go inside this directory until you find the bin version:
~/.gradle/wrapper/dists/gradle-6.8/bin
And now create a symbolic link:
sudo rm /usr/bin/gradle
sudo ln -s ~/.gradle/wrapper/dists/gradle-6.8/bin/gradle /usr/bin/gradle
Check the version:
gradle --version
Will give you this kind of output:
------------------------------------------------------------
Gradle 6.8
------------------------------------------------------------
Build time: 2021-01-08 16:38:46 UTC
Revision: b7e82460c5373e194fb478a998c4fcfe7da53a7e
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.9.1 (Ubuntu 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OS: Linux **********
In android studio, go to Settings->Build,Execution&Deployment,Gradle and change gradle user home to:
~/.gradle/wrapper/dists/gradle-6.8/bin/gradle
Then file->invalidate cache and restart.
Now click on the play button (shift+f10 on linux), on the right of main.dart, it should run smoothly.
