FAILURE: Build failed with an exception.
Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
I tried flutter clean / pug get and update but application is still not working.
Try this:
flutter clean
flutter pub get
Once these two commands have been successfully executed, launch your project ... This is what I did and it worked.
try running
flutter clean
flutter upgrade
it work for me.
In Android Studio I did the following:
flutter clean
flutter pub get
Invalidate Caches and Restart (from the File menu)
After all that, I re-ran the flutter build appbundle command and it worked.
My antivirus was blocking dart from reading asset images, i allowed it from there and the error got fixed!!
I've had the same error and tried the following:
uninstall android studio and delete all folders regarding this
clean up registry
review path for environment variables
give all sorts of flutter commands (clean, update, and so on)
Until I realized this is an error on the flutter folder, so basically this is due to some force close some operations and the variables that write in the 'flutter.gradle' file are obsolete. What I did and worked for me:
Make sure you have all android studio processes closed.
Delete the flutter folder (the one that you defined as for the PATH)
Extract in the same location the flutter folder from the SDK archive.
Enjoy :)
Powershell commands Example:
Remove-Item 'D:\DEV\flutter'
Expand-Archive -LiteralPath 'C:\Archives\flutter_windows_1.22.3-stable.Zip' -DestinationPath D:\DEV
Related
When I tried to run Flutter app on windows, it gives an error then says Exited Sigterm. or stmh like this.
the error says;
Re-run cmake with a different source directory
cmake files does not match...
etc.
The Steps that helped me to handle this error are;
open your terminal then write following commands
flutter clean
flutter pub get
flutter run
This will remove you build file and re-create it.
Your problem should have solved now.
The reason I'm asking it that I'm working on a package, actually flutter plugin and when I reference it local in my apps pubspec.yaml using path: everything works fine and I can see a .packages file being generated inside the local plugin workdir. Now if I now try to reference the plugin using git: in my apps pubspec, flutter pub get is happy BUT when I try to run the app, the build fails with an error mesg:
Launching lib/main.dart on XYZ in debug mode...
/home/maksimlin/.pub-cache/git/edit_exif-3c87efc135c1269b5961ff73696a19e988132ad7/.packages does not exist.
Did you run "flutter pub get" in this directory?
FAILURE: Build failed with an exception.
* Where:
Script '/home/maksimlin/fvm/versions/dev/packages/flutter_tools/gradle/flutter.gradle' line: 896
* What went wrong:
Execution failed for task ':edit_exif:compileFlutterBuildDebug'.
> Process 'command '/home/maksimlin/fvm/versions/dev/bin/flutter'' finished with non-zero exit value 1
and sure enough if I copy the .packages autogenerated file from my local plugin workdir into the the pub-cache location my app builds fine
So is something broken with pub auto-generating .packages for cached from git packages? or have I done something wrong with my plugin?
Unfortunately I can't seem to find much (any) documentation on the usage of .package files, especially for cached packages.
# Generated by pub on 2020-10-01 15:23:17.745081.
args:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.6.0/lib/
bloc:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/bloc-4.0.0/lib/
characters:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0-nullsafety.2/lib/
charcode:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.3/lib/
charts_common:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/charts_common-0.9.0/lib/
cloud_firestore:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.14.0/lib/
cloud_firestore_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_platform_interface-2.0.0/lib/
cloud_firestore_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-0.2.0/lib/
collection:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0-nullsafety.2/lib/
convert:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/
crypto:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.5/lib/
custom_switch:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/custom_switch-0.0.1/lib/
dio:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/dio-3.0.10/lib/
easy_localization:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/easy_localization-2.3.3/lib/
file:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/file-5.2.1/lib/
firebase:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.0/lib/
firebase_auth:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.0/lib/
firebase_auth_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-2.0.0/lib/
firebase_auth_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-0.3.0/lib/
firebase_core:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.5.0/lib/
firebase_core_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-2.0.0/lib/
firebase_core_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-0.2.0/lib/
flutter:file:///C:/Src/flutter/packages/flutter/lib/
flutter_bloc:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bloc-4.0.1/lib/
flutter_localizations:file:///C:/Src/flutter/packages/flutter_localizations/lib/
flutter_web_plugins:file:///C:/Src/flutter/packages/flutter_web_plugins/lib/
google_fonts:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-1.1.0/lib/
http:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/
http_parser:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.4/lib/
intl:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.1/lib/
js:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/
logging:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.4/lib/
matcher:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.9/lib/
material_design_icons_flutter:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/material_design_icons_flutter-4.0.5245/lib/
meta:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/
nested:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/nested-0.0.4/lib/
path:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/
path_provider:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/lib/
path_provider_linux:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/lib/
path_provider_macos:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/lib/
path_provider_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_platform_interface-1.0.2/lib/
pedantic:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.9.2/lib/
platform:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/platform-2.2.1/lib/
plugin_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/plugin_platform_interface-1.0.2/lib/
process:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/process-3.0.13/lib/
provider:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/provider-4.3.2/lib/
quiver:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.3/lib/
shared_preferences:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/lib/
shared_preferences_linux:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/lib/
shared_preferences_macos:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/lib/
shared_preferences_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_platform_interface-1.0.4/lib/
shared_preferences_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/lib/
sky_engine:file:///C:/Src/flutter/bin/cache/pkg/sky_engine/lib/
source_span:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.7.0/lib/
stack_trace:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.5/lib/
string_scanner:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/
term_glyph:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/
typed_data:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0-nullsafety.2/lib/
vector_math:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0-nullsafety.2/lib/
xdg_directories:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/xdg_directories-0.1.0/lib/
website:lib/
This is my .package file here you can see that there is every package that I have used to along with directory(file:///C:/Src/flutter is my directory).
.package is an autogenerated file so you can delete the older one and run flutter pub get so it will generate a newer one.
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!!
Flutter run produces the following error:
Target debug_android_application failed: Exception: Failed to bundle asset files.
build failed.
FAILURE: Build failed with an exception.
Where:
Script '/Users/kirk/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 896
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/kirk/Developer/flutter/bin/flutter'' finished with non-zero exit value 1
Any potential solutions on how to fix this?
i think that you have compatibility issues between the build tools located in android/build.gradle and the gradle located in android/gradle/wrapper/gradle-wrapper.properties, try upgrade or downgrade one of them to be compatible with the other, check this table for compatibilites: https://developer.android.com/studio/releases/gradle-plugincompatibilites
I had exactly the same problem where I couldn't compile or debug my Flutter app. To solve this, just go to tools and in Flutter selection, click on {open project for editing in Android Studio}. This will open only the Android counterpart and you will be able to update your gradle dependencies once the analysis is finished.
I have face similar issues so after spending lot of time i have found if we can write full path for assests file then it works please check below example how it is defined.
assets:
- assets/bg_screen_page.png
- assets/logo.png
After installing flutter and running my emulator it stops at initializing gradle on android studio and on vs code.
It outputs:
this is taking an unexpectedly long time.
I ran flutter doctor and no issues and also flutter doctor -v and still no issues. I tried flutter upgrade but still no difference.
What is the next thing to try?
flutter error log
It looks like it is just taking forever to start; You can read the thread on the issue on
Github:
To summaries: here is one of the issues: Downloading 400mb of dependencies
Solved Initializing gradle problem
The problem is that when first time we are trying to run our flutter
project it does not have the required flutter gradle file. The
required file size that gradle downloads is about 300-400MB that's why
it takes so much time. Following are the steps:
Run your project by clicking on the 'Run' button or flutter run in the command terminal
Then go to the place where your .gradle file is located (usually it is in the C:\Users). In the .gradle folder there is file
name as wrapper in this there is dists folder. In dists folder there
is gradle folder which is being downloaded.
wait till the gradle file is being downloaded and after sometime your project would compile.
its working thaaaaaanks
I am new to mobile development; Everything takes eternity.
Solved this issue by removing all the gradle files from
C:\Users\.gradle\wrapper\dists
Now when you run your flutter app, it will automatically download the required gradle files.
Enjoy!!!