Flutter App stuck at “Running Gradle task 'assembleDebug'… ”

試著忘記壹切 提交于 2020-05-28 12:00:50

问题


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


回答1:


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!




回答2:


Here is solution in my case.

  1. Delete gradle folder in home directory ~/.gradle (optional)
  2. Open your flutter Project directory.
  3. Change directory to android directory in your flutter project directory cd android
  4. clean gradle ./gradlew clean
  5. Build gradle ./gradlew build
  6. Now run your flutter project. If you use vscode, press F5. First time gradle running assembleDebug will take time.



回答3:


There were two reasons for me on Archlinux:

  1. I needed to unset TERM which was set to xterm-256color (reference).
  2. For some reason, flutter stable was not working for me; so I switched to master with: 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).



回答4:


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.




回答5:


If you are on Windows: try adding firewall exceptions to your Android Studio.

  1. Go to:

    Control Panel\System and Security\Windows Defender Firewall\Allowed apps

  2. Hit the button:

    Allow another app

  3. Add your new firewall exceptions:

    studio.exe and studio64.exe

I hope this can be useful for you too.




回答6:


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

  1. Ensure you have installed android sdk tools and added them to the environment path. I assume you have downloaded android sdk tools.

  2. Ensure you have installed gradle and added it to the path

  3. Ensure you have installed latest dart and flutter sdks

For no 1 and 2 please refer to this post:

Setting up flutter without Android studio




回答7:


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:

  1. Interrupt gradle build
  2. Download the required gradle zip from a fast mirror: https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
  3. Copy 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)
  4. flutter run and voilà.



回答8:


This is likely one of number of issues and some of the recommended troubleshooting can be found here.

  1. Check that you are building against an Android sdk that you have installed... in your build.gradle file check the compileSdkVersion.

  2. You can try uninstalling and reinstalling the relevant SDK.

  3. 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.




回答9:


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.




回答10:


Had the same issue because of the wrong compileSdkVersion in the build.gradle file. Working fine now.




回答11:


In my case I forgot to download Google Web Driver. It’s running once I downloaded Google Web Driver.




回答12:


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 doctorflutter 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.




回答13:


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.




回答14:


In my case the Android Gradle Plugin Version was not updated to any version at all. So i updated it by right clicking on my project folder, clicked "Open Module Settings" and updated gradle plugin version accordingly.




回答15:


I used the command "flutter clean" in my project and it returned to work perfectly, please try. Igual a imagem

flutter clean



回答16:


In my case i only needed to wait for flutter to install gradle and other things, if you use the command

flutter run -v

you're able to see what's doing.




回答17:


How are you !,

After many attempts, nothing they recommended worked for me.

My problem was that I had * .dart files with many lines of code to perform SQL create and insert operations initially in SQLite, I removed those 4072 lines of operations, the file was reduced in size and I no longer had to compile a very code file long, instead, I preloaded the database into assets, and it worked flawlessly! ..

The message that the operation is taking a long time no longer appears, I hope it serves you.

Before, when long file size

After, without SQL code operations




回答18:


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.




回答19:


In Android Studio:

Tools -> Flutter -> Flutter clean.

After that just run the app



来源:https://stackoverflow.com/questions/59516408/flutter-app-stuck-at-running-gradle-task-assembledebug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!