When I run the app it get stuck
Launching lib\main.dart on Lenovo A319 in debug mode...
Running Gradle task 'assembleDebug'...
(This is taking an unexpectedly long time.)
It never initialize Gradle nor the dependencies
Here is solution in my case.
cd android
./gradlew clean
./gradlew build
or you can combine both commands with just ./gradlew clean build
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 Running Gradle task assembledebug is taking unexpectedly long time, try updating Gradle in your project. (Downloading latest zip file)
You can follow steps in this answer.
Or try by:
(See screenshot for reference)
This should open the project as an Android Project.
This should open a 'Run Anything' window.
gradlew clean
gradlew build
The update would download the required .zip files. And, your apps should work fine after that.
Flutter
is disabled. In another flutter project which can run sucessful, the Flutter
is enabled. Do you know why?
compileSdkVersion
to 31. The flutter
is still disabled but it just doesn't matter.
I am using VS Code on Ubuntu 18.04
For me it was a background download of the appropriate android sdk build tools for my connected device. Running flutter run -v
showed that it was downloading android SDK build tools which usually take some time. Once it was done, the flutter app compiled and ran successfully.
Solution
Ensure you have installed android sdk tools and added them to the environment path. I assume you have downloaded android sdk tools.
Ensure you have installed gradle and added it to the path
Ensure you have installed latest dart and flutter sdks
For no 1 and 2 please refer to this post:
There were two reasons for me on Archlinux:
unset TERM
which was set to xterm-256color
(reference).flutter channel master
&& flutter upgrade
. I'll be able to switch back to flutter stable when the fix in master makes its way into stable (reference).This worked for me.I got an issue with license acceptance. First you need to go through the flutter directory and then run the command
C:\Users\thrishool\flutterProjects\flutter>flutter doctor
Then it will display if everything is fine or not.I got an issue that, I didnot accept all the licenses.So you need to accept them all.Now type this in cmd
C:\Users\thrishool\flutterProjects\flutter>flutter doctor --android-licenses
Accept all the licenses and you are good to go.
1: If it is the first launch, please be patient since it will download all gradle files for the first time.
2: To know if it really stuck, take help from the task manager in windows or the activity monitor on Mac, and check if the process is really using some CPU or network or not. If not, it is stuck. If it is using some resources, please be patient then (it should take ~5-40 minutes normally, even if you have slower internet).
3: If it is really stuck, stop the process and run ./gradlew clean
before building it next time.
This is likely one of number of issues and some of the recommended troubleshooting can be found here.
Check that you are building against an Android sdk that you have installed... in your build.gradle file check the compileSdkVersion.
You can try uninstalling and reinstalling the relevant SDK.
Some users have reported that they had to resintall Dart.
Without a little more information basic troubleshooting is the best we can offer sorry.
Good luck.
I used the command "flutter clean" in my project and it returned to work perfectly, please try. Igual a imagem
flutter clean
For me simply the process took too much time. It kept running for about 10 mins and finally the app started running.
This problem occurred on my system because of the Zen Kernel.
I installed the Linux-LTS kernel and started system using this.
Then my project backed to compile again.
For creating an apk for Android in Flutter this issue sometimes happens. I had the luck of facing this issue as well. Here are the few ways it can be solved:
1. Due to androidX
If you followed recommended route from here: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
Try this:
Check with steps in “not recommended” way in above tutorial if every listed files is same as in your project, especially :
in root/android/gradle/wrapper/gradle-wrapper.properties set distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
in root/android/build.gradle, set
dependencies { classpath 'com.android.tools.build:gradle:3.3.2' }
check if root/android/app/build.gradle SDK version is set to minimum 28 for:
compileSdkVersion 28 and targetSdkVersion 28
Thank you.
I stumbled on this problem when I was running my app without debugging it. Theres two option
I was doing the second option the whole time which got me stuck in that running graddle loop. I fixed my problem with the first option.
Had the same issue because of the wrong compileSdkVersion in the build.gradle file. Working fine now.
In my case I forgot to download Google Web Driver. It’s running once I downloaded Google Web Driver.
It is taking time on windows 10 as the Android studio needs firewall permission to connect to the device(AVD).
There can be another reason that you don't have downloaded full Android SDK on your machine.
To check the issue simply run the command on your terminal/cmd/PowerShell command tool.
flutter doctor
flutter doctor
check if SDK is installed or not. Try to install and accept license using the following command
flutter doctor --android-licenses
If this doesn't resolve your problem then go to android studio and Open your Android Studio,
File-> settings->System settings(left tab) ->Android SDK
,
go to
SDK Tool section
in that page,
untick hide obsolete packages
,
select Android SDL tools(obsolete)
and press apply also install other useful tools according to your convenience.
This helped: check if root/android/app/build.gradle SDK version is set to minimum 28 for: compileSdkVersion 28 and targetSdkVersion 28
Occurs with import of Firestore.
In my case, I need to update Android SDK built-tools.
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.
I fixed the issue by switching off my antivirus while running my project in the terminal
To run your project in a terminal simply type --> flutter run
This worked for me:
C:\Users<user>\AndroidStudioProjects<flutter_app>\android> gradlew clean C:\Users<user>\AndroidStudioProjects<flutter_app>\android> gradlew build
Now run it, for initial build
“Running Gradle task 'assembleDebug'… ”
will take 10-12 mins after that it will be good to go.
Download the required gradle zip from a fast mirror: https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
Copy gradle-5.6.2-all.zip to C:\Users
.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb
If this does not work, go to android studio's terminal then run:- flutter run.
See what SDK platform it's asking you. like SDK API 28, 29, or 30. Then goto SDK manager and install the required SDK API. Then restart android studio.
It will work perfectly fine!!
The same problem occurred on my mac in Android Studio 4.1, unfortunately, I forgot to install Java on my machine, try installing Java.
nothing was working for me
I do update the flutter SDK & update all the dependencies to the latest version. after that, I open the android
module as a project in android studio. It downloads some files. after completion, I do clean the project using Build->clean Project
& update the Gradle version.
After that, I again open the flutter project and run the app. It's working now.... :)
This might also be due to developers permission, if you will be using any package which requires devices permission lets say url_launcher
and you haven't given permission for that it wont run. Solution for windows is that just run ms-settings:developers
this in your command prompt/ powershell and enable for developers option and then it will work fine.
and if that doesnt also works then just run flutter clean
and flutter create .
it will work.
I cannot edit other answeres so here is mine on top of answere from @Sébastien.
first use flutter run -v
or of you are using Android Studio, edit project configurations
and add -v to the Additional run args
after that running project shows that in my case gradle downloading is taking too much time, so download it directly and unzip it in: C:\Users\ <MyUsername>\.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb
some notes about this address:
gradle folder should be the same name as the file you downloaded so if it ends in bin
instead of all
, use that
the hash at the end is created by default when graddle wrapper starts the download but these are some common ones on my system:
gradle-7.1-bin
:4pslxx9lrxt5svtz5wbnb6tkz
gradle-7.2.1-all
:2hmet7i3y4pg69r05wkkofsqn
gradle-7.3.3-all
:4295vidhdd9hd3gbjyw1xqxpo
gradle-7.5-all
:6qsw290k5lz422uaf8jf6m7co
gradle-7.5.1-all
:1ehga6e77gqps5uk2kc5kf1vc
NOTE inside the said folder there is a file ended in .part
, that is the partially downloaded gradle file, if it is there gradlew will try to complete it, so change the .part
to .ok
, ex: gradle-7.5-all.zip.part
-> gradle-7.5-all.zip.ok
you can also delete it and use an empty file to save some space
(This is taking an unexpectedly long time.)
does it mean after that time it gives back a certain result? if yes, what's the result?flutter run -v
. Lastly, you can try stopping an existing gradle daemon viacd android && ./gradlew --stop
then run theflutter run -v
again.flutter doctor
, this will narrow the bug search area. Does it do that will a specific app or all your apps?