FAILURE: Build failed with an exception - Flutter - android

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

Related

Android Emulator: Gradle task assembleDebug failure on Mac

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!

Flutter build apk failured casue to AndroidManifest.xml path incorrect

I'm building multiple apks for my flutter project.
what I do:
// Add these config to android/app/build.gradle
android {
.
.
.
splits {
abi {
enable true
reset()
include "armeabi-v7a", "arm64-v8a"
universalApk true
}
}
}
Then, run commond line in terminal:
~/Path/project/ $ flutter build apk
but the error occurred:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mpProcessReleaseManifest'.
> java.io.FileNotFoundException: /Users/user/Path/project/android/app/build/intermediates/merged_manifests/release/AndroidManifest.xml (No such file or directory)
* 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 8m 57s
my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-x64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.62.3)
[✓] Connected device (1 available)
• No issues found!
What I tried:
I create a new sample flutter project to test, it's successed.
I compared the AndroidManifest.xml path to test project, I find that in the test project, this file's path is:
/project_test/build/app/intermediates/merged_manifests/release/universal/AndroidManifest.xml
/project_test/build/app/intermediates/merged_manifests/release/arm64-v8a/AndroidManifest.xml
/project_test/build/app/intermediates/merged_manifests/release/armeabi-v7a/AndroidManifest.xml
So I guess that the reason is gradle load this file from android directory but not build, but I don't how to resolve. Someone have same issue?
More info, hope to help:
In project/android/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
}
Just check your manifest file on the current directory
- project file
- android
- app
- src
- main
- AndroidManifest.xml

Flutter throw error while compile code after update flutter to 2.8.1

I use flutter to make my cross platform app the experience is so smooth and it will work above my expectations but after update flutter to 2.8.1 it throw error like I mention below is that error occurs because of my code or there is flutter issue please let me know in comment
Here is my flutter doctor:-
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.5.2 20G95 darwin-x64, locale
en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.59.1)
[✓] Connected device (2 available)
! Error: iPad is busy: Waiting for Device. Xcode will continue when iPad is
finished. (code -10)
! Error: iPhone 7 is not connected. Xcode will continue when iPhone 7 is
connected. (code -13)
• No issues found!
Here is eroor log:-
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No version of NDK matched the requested version 21.0.6113669. Versions available locally: 23.1.7779620
* 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 40s
Exception: Gradle task assembleDebug failed with exit code 1
I think your flutter version can't find ndk in your directory
here is some steps to set ndk in your project
download ndk side by side from sdk manager
Add Ndk path to your local.properties file in android-> local.properties Like this:-
ndk.dir=/Users/imac/Library/Android/sdk/ndk/23.1.7779620
Add ndkVersion in your app build.gradle file in android->app->build.gradle Like this:-
android {
compileSdkVersion 31
ndkVersion '23.1.7779620'
}

FLUTTER : Execution failed for task ':app:compileFlutterBuildDebug' Failed to create parent directory

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.

Flutter build linking failed ttcIndex not found after upgrading to flutter v1.12.13

My flutter app was working without any issue and it worked after I upgraded to flutter v1.12.13+hotfix.5 on debug mode but I get this error when I try to build an APK
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':shared_preferences:verifyReleaseResources'.
1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource
linking failed
D:\my-flutter-app\build\shared_preferences\intermediates\res\merged\release\values\values.xml:236:
error: resource android:attr/fontVaria tionSettings not found.
D:\my-flutter-app\build\shared_preferences\intermediates\res\merged\release\values\values.xml:237:
error: resource android:attr/ttcIndex not found. error: failed
linking references.
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 'assembleRelease'... Running
Gradle task 'assembleRelease'... Done 7.9s
Gradle task assembleRelease failed with exit code 1
My flutter doctor shows no issues
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows
[Version 10.0.18362.592], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK
version 29.0.2)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.41.1)
[√] Connected device (1 available)
• No issues found!
I'm sure that my build.gradle contains compileSdkVersion 28 which is the typical solution for this issue and everything was working before I upgrade.
First of all, you have to find this line in your error log
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource
linking failed [your project path]\build`the package that has the
problem` \intermediates\res\merged\release\values\values.xml
To solve the issue
1- open android studio
2- open the android project of your app. (take care not NOT the app itself)
3- on the left make sure that you view in "project" or "android" view
4- You will find all your packages listed, open expand the package that has the problem\android
5- open the package that has the problem build.gradle
6- make sure that compileSdkVersion 28 not 27
In my case the package that has the problem was shared_preferences
For more information check this issue on flutter github repo
To solve this problem, the command flutter config --enable-build-plugin-as-aar helped me, from here

Categories

Resources