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 more than 20 minutes with no logging or error, I have an intel i5 as a CPU and I'm running it on Linux (dual boot, my download speed is quite slow (200 kb/s average download rate), in case this help
I installed the Flutter SDK and when I try adb devices
on my machine it shows my device connected .
So why it's taking that time to run ? (until now it didn't run yet)
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.
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.
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.
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.
Goto Android Studio - File - Other Setting - Default Project Structure Uncheck use Embeded JDk Below, set your JDK path. Found in Program files - Java - Jdk.
尝试使用flutter run -v ,它基本上会提供在后台运行的信息。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.