Flutter error - Exception: Gradle task assembleDebug failed with exit code -1 - flutter

I'm working on a Flutter Application Project.
For a few days I have an issue when running my application. To test it, I create another project but issue is still present.
I have this exception : Gradle task assembleDebug failed with exit code -1
Issue part 1
Issue part 2
If someone has already encountered this problem or has any idea how to solve it i am really interested.
Thanks in advance.
----- UPDATE ----
My issue came from antivirus program which removed my sdkmanager.bat.
When I was doing "flutter doctor", the license was always "not accepted" and after the command "flutter doctor --android-licenses" the sdkmanager was not found.
Solution
On Windows :
do the command Windows + R
Search msconfig
Go to Services
Hide Windows Services
And find this famous antivirus
To finish, reinstall sdk tools (I have the sdk command line tools (obsolete))
I hope this will help you.

In flutter you can generate APK using this command inside your app directory:
flutter build apk --split-per-abi
This will generate 3 apks for different architecture

I have run into this issue before. This happened to me because terms and conditions that you must accept. First, go to the terminal and run
flutter doctor
It should then show you that you have not accepted the terms, and ask you if you want to accept them now. Follow the instructions on screen and accept each one, there will be around 7. After that relaunch your IDE and it should run fine now.

To reply to your answer #Landon Stahl, I haven't issue when I order flutter doctor
Before try to run
And after try to run app I have : "Android license status unknown"
after try to run

Related

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

Please I need Help Solving this Issue
I have been running my flutter app without issues, but recently I can't run or debug my apps again, each time I try running my app from the terminal or debug console it always get stuck at Flutter App stuck at “Running Gradle task 'assembleDebug'”
C:\Development\projects\flutter>cd kchat
C:\Development\projects\flutter\Kchat>flutter run
Running "flutter pub get" in Kchat... 3.6s
Launching lib\main.dart on GIONEE S10C in debug mode...
Running Gradle task 'assembleDebug'...
(This is taking an unexpectedly long time.)
I have solved the problem by running
flutter run -v
it fixed all the problem but took a longer time, and I can now use
flutter run
but still can't use Debug console
Alternatively, try to fix your project.
Delete the android folder in your project, having previously saved it in another place, then in the terminal run flutter create your_project_name for the folder in which your project is located.

Execution failed for task ':app:cleanMergeDebugAssets' while running the app in flutter

Main error while running the app in Visual Studio Code v1.46.1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:cleanMergeDebugAssets'.
> Unable to delete directory 'E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets\assets
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets\packages\cupertino_icons
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets\packages
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 50s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
This error gets resolved after flutter clean but even that shows the following error
Below is the output of flutter clean
Failed to remove build. A program may still be using a file in the directory or the directory itself. To find and stop such a program, see:
https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used
Deleting build... 19ms
Failed to remove E:\ACNO\Flutter\jots_mobile\.dart_tool. A program may still be using a file in the directory or the directory itself. To find and stop such a program, see:
https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used
Deleting .dart_tool... 21ms
Deleting Generated.xcconfig... 4ms
Deleting flutter_export_environment.sh...
Even when I kill the processes which are using build and .dart_tool folders as mentioned in this answer, flutter clean will show the same error
So, now I've to manually go to file explorer and delete the build & .dart_tool folders, which is the main issue here!
Summary: Main error while running the app gets resolved after flutter clean but even that is showing an error, so now I've to manually go and delete build & .dart_tool folders!
Q. How can I resolve these issues?
Update: Just noticed that this error occurs when I use "f5" to run my program in VS code and not when I use flutter run command in terminal or in Android Studio, but once it has occurred with "f5", it happens with flutter run command and Android Studio both. There is something wrong with the extension in VS Code that enables this "f5" shortcut, I guess!
Checkout these GitHub issues • flutter/flutter • fwcd/vscode-kotlin
The problem was with the Kotlin plugin in VS Code, so removing it should fix our problem!
Now I able to run the project in debug mode. Below is my flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.4, on Microsoft Windows [Version 10.0.17763.1282, locale en-MY)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 4.0)
[√] VS Code (version 1.46.1)
[√] VS Code, 64-bit edition (version 1.46.1)
[√] Connected device (1 available)
I reinstall the Kotlin plugin in VS Code, the problem came back. I removed it, the project runs. So I guess its the plugin. The plugin I used and removed is Kotlin 0.2.17
Can anyone double-check whether the problem is because of this?
Uninstalling the Kotlin 0.2.18 extension on VSCode worked for me. I didn't need to delete the build and .dart_tool files mentioned above.
At the moment I solved using "sudo" mode.
sudo flutter run
I don't have installed Kotlin on VSCode.
I hope to help something
To resolve this, you have to forcefully delete your merged_assets folder and all of its content (i.e 'E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out') since Flutter isn't able to do that for you because one or two programs are using the folders at the background.
To delete the folder forcefully, you can download this exe file: https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer
Then, search for 'merged_assets' in the Find tab. Click on the applications using it and kill them (usually dart.exe and cmd.exe).
After this, run flutter clean
Then re-run your app, it should work successfully.
this problem happen because, some other programs used the same files you need to start compile and run your app, one of the program is live Server, make sure to close it, and close any other programs using this app resources 'files' need to compile .
Write in terminal
cd android
.\gradlew clean
cd ..
and run your progict agin
Or
Enter build file and delete app file
If not working
Enter build file and delete everything inside it
Warning: prefer do a cut and put it in another place.
Because if not working, Returns it in build file again
I did not had the VSCODE KOTLIN plug-in. I just closed VSCODE
and from an elivated (admin) CMD-terminal run
Flutter run
It worked great!!

Task :app:compileFlutterBuildDebug FAILED (Flutter)

I have issue to run demo flutter project.
log verbose :
you can try to use command
flutter clean
and then flutter run
The error might be due to the improper installation of SDK. There are several solutions as per below:
1) Invalid Cache and restart. (the common one)
2) Reinstall flutter SDK.
3) Change the gradle version with the available version of your machine.
4) Removing "android.enableR8=true" line from the android project's gradle.properties file.

Flutter Wrong full snapshot version

I was using Flutter and it was okay, until I run the -flutter upgrade. After that, when I put in debug mode, even when the emulator is already on, debug console shows this message:
Wrong full snapshot version, expected '0c73eb70aa4d30f450273cb424be8c62' found '1d7acad1540192ac459cf60344efb7c1'
Isolate creation failed
Compiler failed on C:\Users\myname\Documents\projetos\16Apps\projeto4\lib\main.dart
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
When I try -flutter doctor, it says that no issues was found.
There is a similar issue reported here at
https://github.com/flutter/flutter/issues/16103
try to use
git clean -xffd

After uninstall app on device flutter run not work

I'm using vs code for building my flutter app.
But after uninstall debug app on my device, 'flutter run' command not working properly and stop in installing status.
Please help me.
Thanks.
Launching lib/main.dart on RNE L21 in debug mode...
Initializing gradle... ۱۱٫۷s
Resolving dependencies... ۱۴٫۹s
Gradle task 'assembleDebug'...
Gradle task 'assembleDebug'... Done ۱۰۱٫۷s
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk... ۶٫۱s
It seems like when you uninstall the flutter application, though it is no longer available on the phone It is not deleted properly(Only in the flutter case). Therefore to fix this. you can run adb and uninstall from the package. Here is a step-by-step procedure.
If you are in windows:
Step 1. Open your SDK path in command prompt
eg.
C:\Users\kharag\AppData\Local\Android\Sdk\platform-tools
Step 2. Search your app package name from the flutter app (It will be in AndroidManifest.xml)
eg.
com.mycodingchannel.icttapp
Step 3. Now uninstall your app by running the command:
adb uninstall com.mycodingchannel.icttapp
That's all, Now run your app and it should work. Thanks
Had the same problem, copied .apk file on device and installed it from there, after that debugger worked without any issues.
Once you see Built/..... in termial. The apk has been created. Now if the installing fails/takes long time. Go to [app folder\app\outputs\apk]
Copy the app.apk/debug.apk any other file to your device and install it.
Now once you re-run it will work fine.
If that doesn't work flutter clean+flutter pub get. Follow the above step.