Build failed - flutter.gradle - flutter

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

Related

Upgrading to flutter 3.0

I am severely getting error:
FAILURE: Build failed with an exception.
Where:
Script '~\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
'~/flutter\bin\flutter.bat' finished with non-zero exit value 1
Currently I am using flutter 2.10.4. Waiting to upgrade with newer version but unfortunately gone few days because of work.
Tried deleting cache and build files. Clean and rebuild the project, nothing works.
Any help would be a great support!

VScode BUILD FAILED Exception: Gradle task assembleDebug failed with exit code 1

I am trying to code an app for the first time with flutter in vs code and I am getting this error,
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\ajgoc\Desktop\Badges\badges_gram\buddies_gram-master\android\build.gradle' line: 29
What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
> 'org.gradle.api.file.DirectoryProperty org.gradle.api.file.ProjectLayout.directoryProperty(org.gradle.api.provider.Provider)'
Exception: Gradle task assembly debug failed with exit code 1
I have tried a couple of things to fix it but haven't gotten anything to work. The app will still load in the emulator but it is an older version of the app. Here is what my gradle-wrapper.poperties and build.gradle files look like.
gradle-wrapper.poperties
build.gradle
flutter doctor -v output

Execution failed for task ':video_player:compileDebugJavaWithJavac'

I am trying to run my flutter project but I can't. I receiving the following error from the console:
Execution failed for task ':video_player:compileDebugJavaWithJavac'. > Compilation failed;
I have tried different versions of the video_player package but it doesn't work.
Please update your android studio.
make sure that you have updated everything in android studio.

Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

debug console looke like this :
FAILURE: Build failed with an exception.
Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
if anyone knows how to solve it plz answer me
I was facing the same issue it's generally related to flutter installation and your java environment if it's any of those you have to completely reinstall flutter and also your Android Studio. If this is the first time you running flutter on your desktop then this might be the problem.
But there are some more quick fixes to try out before taking the above measure
Like clearing out cache and stuff or if there's a problem with the minimum SDK version try exporting the code to a new flutter app or updating/downgrading SDK version.

FAILURE: Build failed with an exception. flutter.gradle' line: 904

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