Flutter App stuck at "Running Gradle task 'assembleDebug'... " - gradle

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.
Open your flutter Project directory.
Change directory to android directory in your flutter project directory cd android
clean gradle ./gradlew clean
Build gradle ./gradlew build or you can combine both commands with just ./gradlew clean build
Now run your flutter project. If you use vscode, press F5. First time gradle running assembleDebug will take time.
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:
Interrupt gradle build
Download the required gradle zip from a fast mirror. e.g. https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
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)
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.
Go to:
Control Panel\System and Security\Windows Defender Firewall\Allowed apps
Hit the button:
Allow another app
Add your new firewall exceptions:
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:
Open a project in Android Studio
Right-click on android in Projects Panel
Go down to Flutter and click on the 'Open Android module in Android Studio'.
(See screenshot for reference)
This should open the project as an Android Project.
Now, click on 'gradle' in the right panel.
Next, click on 'Execute Gradle Task' icon
This should open a 'Run Anything' window.
Now, Run the command gradlew clean
and, then run gradlew build
If prompted by Android Studio to 'Update Gradle Plugin', do that.
The update would download the required .zip files.
And, your apps should work fine after that.

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:
Setting up flutter without Android studio

For me what worked was clean wipe the emulator data by AVD Manager

There were two reasons for me on Archlinux:
I needed to unset TERM which was set to xterm-256color (reference).
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).

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.

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.

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

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.

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.

In Android Studio:
Tools -> Flutter -> Flutter clean.
After that just run the app

I stumbled on this problem when I was running my app without debugging it. Theres two option
Start Debugging
Run without Debugging
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 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.

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

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.

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

I solved the issue by reinstalling SDK Platform on Android studio for Android API 29
Tools->SDK Manager-SDK Platform
Next go to
Android > app > build.gradle
Make sure you also change
compileSdkVersion 29
targetSdkVersion 29
Be patient, it take longer for the first launch...But, not take forever like before.
good luck

Related

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-7.4.2-all.zip'

macbook pro macOS 12.2.1
android studio 2021.2.1 Patch 1
It works well in my company yesterday, I take the computer to home and create a new project or open the available project, when sync the project it show the error: "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-7.4.2-all.zip'."
I try to "invalidate caches.." it doesn't work
I check the .gradle/wrapper/dists folder and it has the 7.4.2 folder, I download gradle-7.4.2-all.zip and move to .gradle/wrapper/dists/7.4.2, It doesn't work
I config the "Build,Execution,Deployment"->"Build Tools"->"Gradle" choose Specified location and set to the locale position, it still doesn't work
I try to delete .gradle folder and "invalidate caches..", it doesn't work.....
I thought maybe the problem is the AndroidStudio can't access network, and try to update Android SDK in android studio(install a new SDK Platforms), it works well
It's so weird...anyone can help me?
Finally solve the problem by remove the Android Studio's Cache. the folder is /Users/myMac/Library/Caches/Google/AndroidStudio2021.2/

Run react native app on Xcode 10

I get this error when i want to run my react native app hello world app on Xcode 10 (new beta version), can you help me?
The error :
error: Build input file cannot be found:
'/Users/nic/Documents/X-Project/xapp/node_modules/react-native/Libraries/WebSocket/libfishhook.a'
Screen shot from my Xcode
This helped me:
Remove and add again libfishhook.a from Xcode and the path issue will resolve.
This issue is caught by the stricter xcode 10 new build system.
A temporary fix while react-native really fix the issue is to switch back to using the old build system
In Xcode, Select File -> Project/Workspace Setting. You will see a Build System option to select the Legacy Build System as shown below
Clear your project and "Derived Data" Build and Run your project
BONUS Point: If you are using a CI/CD pipeline you can also add the xcodebuild argument -UseNewBuildSystem='NO' to the cli or via fastlane xcargs: "-UseNewBuildSystem='NO'"
Manually copypasting libfishhook.a into the correct folder, as suggested here, worked for me:
For a solution, I copied the file from my ios/build/Build/Products/Debug-iphonesimulator/libfishhook.a and pasted it into ../node_modules/react-native/Libraries/WebSocket/ and got the build. I hope it helps.
...
Daniel's answer helped me to solve problem. Just note that if it's tvOS, then the same action of removing and adding should be done of RCTWebSocket-tvOS.a

Nativescript building android errors

I have a nativescript (3.0) application which I am developing on mac (ElCapitan). I am able to run the iOS emulator without a problem, but I cannot find a way to build the app for Android. I am getting the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MyApp'.
> Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.004 secs
Command ./gradlew failed with exit code 1
I followed the nativescript documentation strictly, removed the android platform and added it again, reinstalled the Android SDK and tools, but without any success.
At this point I am out of ideas. Any help would be greatly appreciated.
Thank you.
did you try nuke it?
tns plugin remove nativescript-telerik-ui
tns plugin add nativescript-telerik-ui
my be you have an older version
It seems you have changed something on the "AndroidManifest.xml" file and which is not correct. Please fix the "AndroidManifest.xml" file.
If not, you can try this
tns platform remove android
tns platform add android
if only these two lines are not enough for the solution, you may run the android platform on Android Studio.
app/platforms/android
This is the directory, you have to open on Android Studio. After opening this, Android Studio will suggest to you what you have to do.

Phonegap Build is failing due to dependency error

Im building the Phonegap App using Phonegap Build.
Phonegap Build cant create Android APK, build is failing with below error, Morning I was able to create the APK but now below error is thrown. Note that there is no config file changes between morning and now.
Please help
App Id: 2074580
https://build.phonegap.com/apps/2074580/builds
Could not resolve all dependencies for configuration ':_debugCompile'.
Could not find com.android.support:support-v4:23.4.0.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/support/support-v4/23.4.0/support-v4-23.4.0.pom
https://repo1.maven.org/maven2/com/android/support/support-v4/23.4.0/support-v4-23.4.0.jar
file:/android-sdk/extras/android/m2repository/com/android/support/support-v4/23.4.0/suppo rt-v4-23.4.0.pom
file:/android-sdk/extras/android/m2repository/com/android/support/support-v4/23.4.0/suppo rt-v4-23.4.0.jar
file:/android-sdk/extras/google/m2repository/com/android/support/support-v4/23.4.0/suppor t-v4-23.4.0.pom
file:/android-sdk/extras/google/m2repository/com/android/support/support-v4/23.4.0/suppor t-v4-23.4.0.jar
Required by:
:project:unspecified
I had a similar problem with this plugin. I needed to update some android libraries. This command solved it all for me:
android update sdk --no-ui --all --filter "extra-android-m2repository"
If you don't have the android command in your command line, you can navigate to the SDK directory.
Answered here; https://github.com/phonegap/phonegap-plugin-push/issues/928. You need to switch back to Cordova version 1.6.3 or 1.6.4. But I just checked and upgrading to the latest nightly build also seems to fix it. When working in Visual Studio, clear the cordova cache too (after setting the correct version):
Tools => Options => Tools for Apache Cordova => Clear Cordova Cache.

Grunt, Cordova & Windows Phone

I am developing an app for multiple platforms using Cordova. Grunt is used as a build tool. I use it to copy my source code to the right folder for each platform so I can develop them independently.
This works fine with Android using the scripts that are provided by Cordova. However, I have no idea if or how it is possible to automate the WP build process. I'm looking for two things:
Add all files in the www directory to the VS project (it does not include files that are not added to the project, which is sad).
Build, install and run the app in the emulator. I used adb & Grunt's exec for Android which was really simple, is there something similar for WP?
If you look in a cordova windows phone project there is a directory called 'cordova' which contains scripts to do all of this.
There should be scripts to build and run your project.
The run script can pretty much do it all. You can call it like :
run --device --release
or
run --emulator --debug
or just
run
A recent commit now makes it possible to use www\** in the .csproj file, which solved my first issue.

Resources