Search code examples
flutterdartbuild.gradleflutter-buildflutter-apk

Execution failed for task ':app:compileFlutterBuildRelease', please how do I solve this issue


Am having problem building my project, when I build it in debug mode it goes fine but when I build it in profile mode and release mode it gives me error. And If I do flutter run for debug mode it successfully build and throws me a new error.

Dart snapshot generator failed with exit code -1073741819
Target android_aot_release_android-arm failed: Exception: AOT snapshotter exited with code -1073741819


FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Lenovo\Desktop\ALL\Flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\Users\Lenovo\Desktop\ALL\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 4m 32s
Running Gradle task 'assembleRelease'...                          275.1s
Gradle task assembleRelease failed with exit code 1

Thats the error I get when I run flutter build apk --release

And I get this error when I run flutter build apk --profile

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':connectivity_plus:verifyProfileResources'.
> Could not resolve all files for configuration ':connectivity_plus:profileRuntimeClasspath'.
   > Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for AarResourcesCompilerTransform: C:\Users\Lenovo\.gradle\caches\transforms-3\5f7c8bec4875ba55b1273d724949c5bc\transformed\core-1.6.0.
         > AAPT2 aapt2-7.2.0-7984345-windows Daemon #1: Daemon startup failed
           Please check if you installed the Windows Universal C Runtime.
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
      > Execution failed for AarResourcesCompilerTransform: C:\Users\Lenovo\.gradle\caches\transforms-3\5f7c8bec4875ba55b1273d724949c5bc\transformed\core-1.6.0.
         > AAPT2 aapt2-7.2.0-7984345-windows Daemon #1: Daemon startup failed
           Please check if you installed the Windows Universal C Runtime.
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
      > Execution failed for AarResourcesCompilerTransform: C:\Users\Lenovo\.gradle\caches\transforms-3\5f7c8bec4875ba55b1273d724949c5bc\transformed\core-1.6.0.
         > AAPT2 aapt2-7.2.0-7984345-windows Daemon #1: Daemon startup failed
           Please check if you installed the Windows Universal C Runtime.
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
      > Execution failed for AarResourcesCompilerTransform: C:\Users\Lenovo\.gradle\caches\transforms-3\5f7c8bec4875ba55b1273d724949c5bc\transformed\core-1.6.0.
         > AAPT2 aapt2-7.2.0-7984345-windows Daemon #1: Daemon startup failed
           Please check if you installed the Windows Universal C Runtime.
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
      > Execution failed for AarResourcesCompilerTransform: C:\Users\Lenovo\.gradle\caches\transforms-3\5f7c8bec4875ba55b1273d724949c5bc\transformed\core-1.6.0.
         > AAPT2 aapt2-7.2.0-7984345-windows Daemon #1: Daemon startup failed
           Please check if you installed the Windows Universal C Runtime.
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
      > Execution failed for AarResourcesCompilerTransform: C:\Users\Lenovo\.gradle\caches\transforms-3\5f7c8bec4875ba55b1273d724949c5bc\transformed\core-1.6.0.
         > AAPT2 aapt2-7.2.0-7984345-windows Daemon #1: Daemon startup failed
           Please check if you installed the Windows Universal C Runtime.
           This should not happen under normal circumstances, please file an issue if it does.

* 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 18m 30s
Running Gradle task 'assembleProfile'...                         1114.7s
Gradle task assembleProfile failed with exit code 1

Then I get success when building for debug mode, but if am running the debug mode this what I get

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Running Gradle task 'assembleDebug'...                           1721.3s
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Failed to extract manifest from APK: ProcessException: The command failed
  Command: C:\Users\Lenovo\AppData\Local\Android\sdk\build-tools\33.0.2\aapt dump xmltree
  C:\Users\Lenovo\Desktop\ALL\Flutter-Apps\portfolio\build\app\outputs\flutter-apk\app-debug.apk AndroidManifest.xml.
Exception: Problem building Android application: see above error(s).

So I decided to upgrade flutter to the latest which is 3.7.8 since almost every solution I see on the internet is not working and even other answer on same issue is not working, have checked the flutter community and no solution.

I decided to create a new project and run it, behold got a the same error!!!

Running Gradle task 'assembleDebug'...                            715.1s
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Failed to extract manifest from APK: ProcessException: The command failed
  Command: C:\Users\Lenovo\AppData\Local\Android\sdk\build-tools\33.0.2\aapt dump xmltree
  C:\Users\Lenovo\Desktop\ALL\Flutter-Apps\food\build\app\outputs\flutter-apk\app-debug.apk AndroidManifest.xml.
Exception: Problem building Android application: see above error(s).

Please what should I do? I need help

This my Flutter doctor -v @Hoa Le

[√] Flutter (Channel stable, 3.7.8, on Microsoft Windows [Version 10.0.22000.318], locale en-US) • Flutter version 3.7.8 on channel stable at C:\Users\Lenovo\Desktop\ALL\Flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 90c64ed42b (9 days ago), 2023-03-21 11:27:08 -0500 • Engine revision 9aa7816315 • Dart version 2.19.5 • DevTools version 2.20.1

This is taking an unexpectedly long time...[√] Windows Version (Installed version of Windows is version 10 or higher)

Checking Android licenses is taking an unexpectedly long time...[☠] Android toolchain - develop for Android devices (the doctor check crashed) X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. X Exception: Android toolchain - develop for Android devices exceeded maximum allowed duration of 0:04:30.000000 •

[√] Android Studio (version 2021.3) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.73.1) • VS Code at C:\Users\Lenovo\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.60.0

[☠] Connected device (the doctor check crashed) X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. X Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: C:\Users\Lenovo\AppData\Local\Android\sdk\platform-tools\adb.exe • #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:75:7) #2 PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:394:54) #3 Future.wait. (dart:async/future.dart:522:21) #4 DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:182:40) #5 DeviceValidator.validate (package:flutter_tools/src/doctor.dart:690:34) #6 Future.any.onValue (dart:async/future.dart:612:5)

[√] HTTP Host Availability • All required HTTP hosts are available

! Doctor found issues in 2 categories.


Solution

  • I later found out that most dependencies for app build was not installed because of network issues and I resolve this as downgrading and upgrading flutter again which it installed all the dependencies

    flutter downgrade v3.7.8
    

    then you upgrade it again to v3.7.9 or later by doing

    flutter upgrade --force
    

    to upgrade it. But if you experience any error while downloading it caused by network issues. And when this error happens you need to repeat this whole process till it is successful.

    Thank you.