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)
gradle, if you have minifyEnabled for debug, remove it. I had it in my project and it took ~2-3 minutes to build.
When you are going to build the Flutter app for the first time, it takes a very long time than usual because Flutter builds a device-specific IPA or APK file. In this process, the Xcode and Gradle are used to build a file, which usually takes a long time.
Dynamic Dependencies slow down your build since they keep searching for the latest builds every time. To improve the performance we need to fix the version in place. Use only those dependencies that you need.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With