I am trying to run my Android project on the emulator, but I am encountering the following error: "Gradle task assembleDebug failure." I have tried several solutions, but nothing seems to work. Can someone help me resolve this issue?
* Where:
Script '/Users/myname/FlutterDev/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1151
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/myname/FlutterDev/flutter/bin/flutter'' 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 2s
Exception: Gradle task assembleDebug failed with exit code 1
Also I check my flutter doctor everything its checked
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.1, on macOS 13.2 22D49 darwin-arm64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.75.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
Related
I'm using Ubuntu 20.04. I've reinstalled flutter and android studio a few times but I can't make the below error go away. I've also tried the commands flutter clean and gradlew clean and tried to change compileSdkVersion, minSdkVersion and targetSdkVersion.
Launching lib/main.dart on sdk gphone x86 in debug mode...
lib/main.dart:1
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not create service of type UserHomeScopedCompileCaches using UserHomeScopeServices.createCompileCaches().
Unexpected lock protocol found in lock file. Expected 3, found 0.
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 36s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
When I run flutter doctor:
$: flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.1, on Ubuntu 20.04.4 LTS 5.13.0-44-generic,
locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Android Studio
[✓] VS Code
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
Java and javac:
$: java --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
$: javac --version
javac 11.0.15
I copied my project from another PC and I try to run my application on the real device then I got this error code :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Failed to create parent directory 'C:\Users\user' when creating directory 'C:\Users\user\AndroidStudioProjects\app_name\android\app\build\intermediates\flutter\debug\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
I tried using flutter clean but still the same
Then this result of my flutter doctor :
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19042.1237], locale en-ID)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio
[√] VS Code (version 1.60.2)
[√] Connected device (3 available)
• No issues found!
I fixed my problem by deleting the build folder in the android/app directory.
after this
flutter clean
then
Flutter run
Try deleting the build.gradle in the android directory.
I'm getting this error message when trying to build my Flutter app on Android. It was running fine since I started this project a couple of days ago. After doing some testing on IOS simulator I had to try some stuff on Android again and couldn't build it anymore.
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
ERROR:/Users/Antonio/Dropbox/Flutter/wader/build/app/intermediates/packaged_manifests/debug/AndroidManifest.xml:22: AAPT: error: 'orientation|keyboardHidden|keyboard|viewsize|smallestviewsize|locale|layoutDirection|fontScale|screenLayout|density|uiMode' is incompatible with attribute configChanges (attr) flags [colorMode=16384, density=4096, fontScale=1073741824, keyboard=16, keyboardHidden=32, layoutDirection=8192, locale=4, mcc=1, mnc=2, navigation=64, orientation=128, screenLayout=256, screenSize=1024, smallestScreenSize=2048, touchscreen=8, uiMode=512].
* 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 1m 40s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin connectivity...
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assembleAarRelease' not found in root project 'connectivity'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 4s
Exception: The plugin connectivity could not be built due to the issue above.
Exited (sigterm)
This is my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.7 19H1030 darwin-x64,
locale en-AE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.44.0)
[✓] VS Code (version 1.43.2)
[✓] Connected device (2 available)
• No issues found!
Any ideas?
With Android Studio, I created a new Flutter project and copied the following files:
I get following exception when building flutter apk or appbundle. It happens randomly. I don't know what triggers it. How can I debug this further?
Dart snapshot generator failed with exit code -9
FAILURE: Build failed with an exception.
* Where:
Script '/var/theproject/libs/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/var/theproject/libs/flutter/bin/flutter'' 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 6m 51s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 412.5s
Gradle task assembleRelease failed with exit code 1
Here is my flutter doctor -v result:
Flutter (Channel stable, 2.2.2, on Linux, locale en_US.UTF-8)
• Flutter version 2.2.2 at /var/theproject/libs/flutter
• Framework revision d79295af24 (6 days ago), 2021-06-11 08:56:01
-0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[✓] Android toolchain - develop for Android devices (Android SDK version
29.0.3)
• Android SDK at /var/theproject/libs/android-sdk-linux
• Platform android-30, build-tools 29.0.3
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_282-b08)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at
google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome
executable.
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit
https://flutter.dev/docs/get-started/install/linux#android-setup for
detailed instructions).
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
I had the same problem, what it solved was to use variables from other class with static and not by creating a instance:
Works fine:
import file
ClassName.variable
Bug:
import file
var instance = ClassName()
instance.variable
I was trying to build my app but it always returns this weird error :-
Launching lib\main.dart on M2003J15SC in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':location:compileDebugJavaWithJavac'.
> File 'C:\Native\findhelpapp\findhelpapp\build\location\intermediates\annotation_processor_list\debug\annotationProcessors.json' specified for property 'processorListFile' does not exist.
* 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 52s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I tried to run flutter clean and rebuild the project and it doesn't work too :"(
So what should I do to fix this error??
My flutter doctor logs :-
C:\Native\findhelpapp\findhelpapp>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.18362.1082], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.6)
[√] IntelliJ IDEA Community Edition (version 2019.3)
[√] VS Code (version 1.49.1)
[√] Connected device (1 available)
• No issues found!
C:\Native\findhelpapp\findhelpapp>
Check Android SDK and Jdk Location
2.Copy next lines at the end of gradle.properties
android.useAndroidX=true
android.enableJetifier=true
And set the latest version
on file app\build.gradle
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
4.And Run your app a
gain