Open in Android Studio Tools->SDK Manager–SDK Tools. Mark Android SDK Built-Tools, press Apply, wait for the update. After updated, press Apply and try to run. will take 10-12 mins after that it will be good to go.
Enable build caching For example, ./gradlew assembleDebug --build-cache . You can also configure build caching on your gradle. properties file. Estimates that this will improve your full clean build by up to 3 times faster, and incremental builds by up to 10 times faster!
Gradle is a build system used to build Android apps. Android developers use Android Studio and Gradle to build Android apps. Now with Flutter the future of mobile development, we develop one app (Dart language) and it runs on three platforms(Android, iOS, and Web). We need to learn Flutter and Gradle configuration.
AnswerOpen the build. gradle file on android/app folder and set the compileSdkVersion & targetSdkVersion to 31 and set the minSdkVersion to 21 so that it would be compatible to older versions of android.
Here is solution in my case.
cd android
./gradlew clean
./gradlew build
or you can combine both commands with just ./gradlew clean build
(Thanks @daniel for the tip)PS: Delete gradle in case of all that steps don't work
flutter run -v
showed that I was stuck on
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
This was going to take hours, as for some reason the download speed was ~10kB/s on a decent DSL connection.
Solution:
gradle-5.6.2-all.zip
to C:\Users\
<MyUsername>\.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb
(of course the last folder will have a different name on your PC)flutter run
and voilà.In my case, Windows Firewall was causing this problem. After I disabled it temporarily the problem was gone. Worth giving it a try. Good luck!
If you are on Windows: try adding firewall exceptions to your Android Studio.
Control Panel\System and Security\Windows Defender Firewall\Allowed apps
Allow another app
studio.exe and studio64.exe
I hope this can be useful for you too.
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