Why do I get "FAILURE: Build failed with an exception."? - flutter

When I try to start my app I get an error. I think I get the error because I tried to add a video in my app, because before I did this everything worked without an error.
This is the error:
Launching lib\main.dart on SM J530F in debug mode...
Running Gradle task 'assembleDebug'...
Target debug_android_application failed: FileSystemException: Cannot copy file to 'C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\build\app\intermediates\flutter\debug\flutter_assets\assets/coffee.mp4', path = 'C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\assets\coffee.mp4' (OS Error: Zugriff verweigert
, errno = 5)
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Simon\Desktop\App Entwickeln\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\Simon\Desktop\App Entwickeln\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 26s
Exception: Gradle task assembleDebug failed with exit code 1

Try flutter clean then build again

That looks like a file permissions related issue. Do you get error when you try below code in command line? If you have you need to check permission of the path you gave.
copy "C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\assets\coffee.mp4" "C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\build\app\intermediates\flutter\debug\flutter_assets\assets/coffee.mp4"

Related

Error: The method 'copyWith' isn't defined for the class 'RouteSettings'

I'm trying to run a sample of flutter , that thingsboard.io published in this starting guide.
sample code : https://github.com/thingsboard/flutter_thingsboard_app
when i run start debuging in VS Code, i get this error:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
/C:/src/flutter/.pub-cache/hosted/pub.dev/fluro-2.0.3/lib/src/fluro_router.dart:134:37: Error: The method 'copyWith' isn't defined for the class 'RouteSettings'.
- 'RouteSettings' is from 'package:flutter/src/widgets/navigator.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/navigator.dart').
Try correcting the name to the name of an existing method, or defining a method named 'copyWith'.
settingsToUse = settingsToUse.copyWith(name: path);
^^^^^^^^
Target kernel_snapshot failed: Exception
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)
* 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 2m 8s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
i'm newborn in mobile application, please help me, what should i do?
i want run this sample by VS code.

Error FAILURE: Build failed with an exception when running flutter emulator

I am getting error like this while running flutter with emulator in vscode. I have downloaded sdk and downloaded pixel api 30, how to solved it and I can run my code with emulator andoid?
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Denis\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\Denis\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 32s
Exception: Gradle task assembleDebug failed with exit code 1

Getting an error white running flutter application "FAILURE: build failed with an exception"

I am getting an error while running my flutter application through vscode the error "FAILURE: build failed with an exception"
I attach the full error below.
Since I am new to this environment I don't know about this, please help me, Thank you!
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1256
* What went wrong:
Could not determine the dependencies of task ':app:compileFlutterBuildDebug'.
> Index 1 out of bounds for length 1
* 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 18s
Exception: Gradle task assembleDebug failed with exit code 1

Error incorrect settings while building a flutter project

i work on windows and i get this error while running a flutter project , so it work on chrome but on the real device phone or emulator it does not .
this the error :
Format incorrect du param�tre -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shared_preferences_android:parseDebugLocalResources'.
> Could not resolve all files for configuration ':shared_preferences_android:androidApis'.
> Failed to transform android.jar to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for PlatformAttrTransform: C:\Users\MEJDI BEN HAMIDA\AppData\Local\Android\sdk\platforms\android-31\android.jar.
> zip END header not found
* 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 7s
Running Gradle task 'assembleDebug'... 8,9s
Exception: Gradle task assembleDebug failed with exit code 1

Execution failed for task ':app:compileFlutterBuildDebug'. > Process 'command 'C:\Users\DELL\Documents\flutter\bin\flutter.bat''

Launching lib\main.dart on Android SDK built for x86 in debug mode...
: Error: Expected ';' after this.
});0
^
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\DELL\Documents\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\DELL\Documents\flutter\bin\flutter.bat'' finished with non-zero exit value 1
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 26s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Github : https://github.com/Pavel401/rainbow
I tried to find " });0" in all dart files but couldn't find anything.It took me 30 days of work to get here . I added the repo link for code .