Initializing Gradle is taking forever on android studio for Flutter project
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.
- After Downloading it visit to :/Users//.gradle/wrapper/dists/gradle-4.10.2-all/9fahxiiecdb76a5g3aw9oi8rv your version path may vary and paste downloaded zip inside it.
- For Dependencies to download you need to wait depending on Internet speed.
- It is one time process until next updated version and dependencies come UP.
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.
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
Changegradle-5.4.1-all
with the folder name you copied in step 2.Run your app, and hopefully it works this time.