I\'m trying to run a hello world flutter app for the first time on my device, but when I hit run on android studio, it shows initilizing gradle, and it stays like that for m
The problem is that Gardle is downloading dependencies and not using any way to show progress(This is NOT good for UX), so it is better to run gradlew.bat
in the terminal and things will become more clear, like this:
Now it is much better, You can have a cup of coffee while watching it ;)
https://github.com/flutter/flutter/issues/15106
Please note riftninja's answer. I look at this directory: C:\Users\myname.gradle\wrapper\dists Yes, the gradle file is really big: 87M. You have to wait for a long time. After this will be "Resolving dependencies....", which also slowly. But finally it succeed.
When running flutter project first time even correct configuration it takes very long time. That is because of downloading gradel and dependencies for particular version.If you ar noob Wait it to complete automatically till all files get downloaded. By using command:
flutter run <project-name> -v
you can see whats happening in background.
To Manually downloading gradle zip and put to suitable directory. Go in Project Dir: /android/gradle/wrapper/gradle-wrapper.properties and click on url and download it.
I've faced the same problem, and my internet is currently very slow, so I solved it by changing the gradle in flutter project to an already downloaded one. Just follow these steps:
Go to C:\Users\YOUR_USER_NAME\.gradle\wrapper\dists
You should find one or more folders with the name of the distribution (for example with the name "gradle-4.6-all" if you were developing in Android Studio previously), choose one of these folders (make sure it is not empty) and copy its name.
Open Android Studio project explorer, and locate android\gradle\wrapper\gradle-wrapper.properties
You will find a line like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Change gradle-5.4.1-all
with the folder name you copied in step 2.
Run your app, and hopefully it works this time.
Goto Android Studio - File - Other Setting - Default Project Structure Uncheck use Embeded JDk Below, set your JDK path. Found in Program files - Java - Jdk.
Providing an active internet connection worked for me.
To build gradle offline,
For Windows,
Go to File -> Settings.
And open the 'Build,Execution,Deployment'. Then open the
Build Tools -> Gradle
Then check the box -> Offline work below.
Click the OK button.
For Mac OS,
go to Android Studio -> Preferences, and the rest is the same.