Example Hello world flutter app build failed: Execution failed for task ':app:mergeDebugResources'

6,624

Solution 1

Finally I knew what cause the problem: it is restrictions to run programs in other places then Program Files, Program Data, etc. After I set up in Android Studio example project and flutter run -v I saw error message:

this program is blocked by group policy. for more information contact your system administrator

I've run flutter run -v in admin console and it worked. I think gradle try to download and run sth in c:\users\<user>\.gradle - anyone know how to fix this?

Solution 2

android-arm64-release is for release builds, while mergeDebugResources is a task from a debug build. If any log would be interesting, that would be (this might be just as non-telling as the other log, when it cannot start AAPT2):

gradlew.bat --stacktrace assembleDebug
  • When AAPT2 fails with task mergeDebugResources, maybe the resources are at fault.

  • When AAPT2 cannot start, that might be the UCRT... but aapt2 is a JAR.

  • Setting GRADLE_USER_HOME as environmental variable on Windows.

Even if option #1 is unlikely for some "hello world" program... I'd suggest trying to build a regular Android project ...just to get rid of all the Flutter complexity, in order to see if AAPT2 even starts.

Solution 3

Typically this means you're missing the windows universal C runtime library. However, since you stated you're using windows 10, it looks like for some reason your system is missing this C runtime library even though it should have came installed (or in an update). You can get this missing library by installing Microsoft Visual C++ Redistributable for Visual Studio (current 2019) from here.

Share:
6,624
Wiszen
Author by

Wiszen

Currently working with Oracle APEX.

Updated on December 16, 2022

Comments

  • Wiszen
    Wiszen over 1 year

    I've recently installed flutter and tried to run example app that is created by flutter(editor VSCode) but I've got following error (also build command failed):

    flutter run
    Launching lib\main.dart on SM J730F in debug mode...
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:mergeDebugResources'.
    > Multiple task action failures occurred:
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #1: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #6: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #0: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #3: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #4: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #2: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #5: Daemon startup failed
            This should not happen under normal circumstances, please file an issue if it does.
       > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
          > AAPT2 aapt2-3.5.0-5435860-windows Daemon #7: Daemon startup failed
            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 29s
    Running Gradle task 'assembleDebug'...
    Running Gradle task 'assembleDebug'... Done                        31,2s
    Gradle task assembleDebug failed with exit code 1
    

    Code is not changed (lib/main.dart):

    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            // This is the theme of your application.
            //
            // Try running your application with "flutter run". You'll see the
            // application has a blue toolbar. Then, without quitting the app, try
            // changing the primarySwatch below to Colors.green and then invoke
            // "hot reload" (press "r" in the console where you ran "flutter run",
            // or simply save your changes to "hot reload" in a Flutter IDE).
            // Notice that the counter didn't reset back to zero; the application
            // is not restarted.
            primarySwatch: Colors.blue,
          ),
          home: MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      MyHomePage({Key key, this.title}) : super(key: key);
    
      // This widget is the home page of your application. It is stateful, meaning
      // that it has a State object (defined below) that contains fields that affect
      // how it looks.
    
      // This class is the configuration for the state. It holds the values (in this
      // case the title) provided by the parent (in this case the App widget) and
      // used by the build method of the State. Fields in a Widget subclass are
      // always marked "final".
    
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      int _counter = 0;
    
      void _incrementCounter() {
        setState(() {
          // This call to setState tells the Flutter framework that something has
          // changed in this State, which causes it to rerun the build method below
          // so that the display can reflect the updated values. If we changed
          // _counter without calling setState(), then the build method would not be
          // called again, and so nothing would appear to happen.
          _counter++;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        // This method is rerun every time setState is called, for instance as done
        // by the _incrementCounter method above.
        //
        // The Flutter framework has been optimized to make rerunning build methods
        // fast, so that you can just rebuild anything that needs updating rather
        // than having to individually change instances of widgets.
        return Scaffold(
          appBar: AppBar(
            // Here we take the value from the MyHomePage object that was created by
            // the App.build method, and use it to set our appbar title.
            title: Text(widget.title),
          ),
          body: Center(
            // Center is a layout widget. It takes a single child and positions it
            // in the middle of the parent.
            child: Column(
              // Column is also a layout widget. It takes a list of children and
              // arranges them vertically. By default, it sizes itself to fit its
              // children horizontally, and tries to be as tall as its parent.
              //
              // Invoke "debug painting" (press "p" in the console, choose the
              // "Toggle Debug Paint" action from the Flutter Inspector in Android
              // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
              // to see the wireframe for each widget.
              //
              // Column has various properties to control how it sizes itself and
              // how it positions its children. Here we use mainAxisAlignment to
              // center the children vertically; the main axis here is the vertical
              // axis because Columns are vertical (the cross axis would be
              // horizontal).
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'You have pushed the button this many times:',
                ),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.display1,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: _incrementCounter,
            tooltip: 'Increment',
            child: Icon(Icons.add),
          ), // This trailing comma makes auto-formatting nicer for build methods.
        );
      }
    }
    

    ./android/build.gradle:

    buildscript {
        ext.kotlin_version = '1.3.50'
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    ./android/app/build.gradle:

    def localProperties = new Properties()
    def localPropertiesFile = rootProject.file('local.properties')
    if (localPropertiesFile.exists()) {
        localPropertiesFile.withReader('UTF-8') { reader ->
            localProperties.load(reader)
        }
    }
    
    def flutterRoot = localProperties.getProperty('flutter.sdk')
    if (flutterRoot == null) {
        throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
    }
    
    def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
    if (flutterVersionCode == null) {
        flutterVersionCode = '1'
    }
    
    def flutterVersionName = localProperties.getProperty('flutter.versionName')
    if (flutterVersionName == null) {
        flutterVersionName = '1.0'
    }
    
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
    
    android {
        compileSdkVersion 28
    
        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }
    
        lintOptions {
            disable 'InvalidPackage'
        }
    
        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId "pl.my.app-phrog"
            minSdkVersion 16
            targetSdkVersion 28
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                // TODO: Add your own signing config for the release build.
                // Signing with the debug keys for now, so `flutter run --release` works.
                signingConfig signingConfigs.debug
            }
        }
    }
    
    flutter {
        source '../..'
    }
    
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    }
    

    ./android/gradle.properties:

    org.gradle.jvmargs=-Xmx4608M
    android.enableR8=true
    android.useAndroidX=true
    android.enableJetifier=true
    

    Flutter doctor:

    [√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.17134.1069], locale pl-PL)
        • Flutter version 1.12.13+hotfix.5 at (...)
        • Framework revision 27321ebbad (4 weeks ago), 2019-12-10 18:15:01 -0800
        • Engine revision 2994f7e1e6
        • Dart version 2.7.0
    
    
    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
        • Android SDK at (...)
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-29, build-tools 29.0.2
        • ANDROID_HOME = (...)
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
        • All Android licenses accepted.
    
    [√] Android Studio (version 3.5)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin version 42.1.1
        • Dart plugin version 191.8593
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    
    [√] VS Code (version 1.41.1)
        • VS Code at (...)
        • Flutter extension version 3.7.1
    
    [√] Connected device (1 available)
        • SM J730F • android-arm • Android 9 (API 28)
    
    • No issues found!
    

    Gradle stack trace:

    #0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
    #1      buildGradleApp (package:flutter_tools/src/android/gradle.dart:431:7)
    #2      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
    #3      _rootRunUnary (dart:async/zone.dart:1134:38)
    #4      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
    #5      _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
    #6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
    #7      Future._propagateToListeners (dart:async/future_impl.dart:709:32)
    #8      Future._completeWithValue (dart:async/future_impl.dart:524:5)
    #9      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
    #10     _rootRun (dart:async/zone.dart:1126:13)
    #11     _CustomZone.run (dart:async/zone.dart:1023:19)
    #12     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
    #13     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
    #14     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
    #15     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
    #16     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
    #17     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:175:5)
    

    EDIT: I've run command with verbose option:

    $ flutter run -v
    [  +63 ms] executing: [...\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [ +264 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [   +4 ms] 27321ebbad34b0a3fafe99fac037102196d655ff
    [   +1 ms] executing: [...\flutter\] git describe --match v*.*.* --first-parent --long --tags
    [ +231 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
    [        ] v1.12.13+hotfix.5-0-g27321ebba
    [  +13 ms] executing: [...\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
    [ +213 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
    [   +1 ms] origin/stable
    [   +1 ms] executing: [...\flutter\] git ls-remote --get-url origin
    [ +210 ms] Exit code 0 from: git ls-remote --get-url origin
    [   +1 ms] https://github.com/flutter/flutter.git
    [ +294 ms] executing: [...\flutter\] git rev-parse --abbrev-ref HEAD
    [ +219 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [   +1 ms] stable
    [ +232 ms] executing: ...\Android\Sdk\platform-tools\adb.exe devices -l
    [ +112 ms] Exit code 0 from: ...\Android\Sdk\platform-tools\adb.exe devices -l
    [   +1 ms] List of devices attached
               52009f78e2ae3433       device product:j7y17ltexx model:SM_J730F device:j7y17lte transport_id:6
    [  +34 ms] ...\Android\Sdk\platform-tools\adb.exe -s 52009f78e2ae3433 shell getprop
    [ +228 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
    [  +28 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [   +9 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [ +903 ms] Generating ...\hello_world_flutter\new_hello_flutter\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
    [ +111 ms] ro.hardware = samsungexynos7870
    [ +140 ms] Launching lib\main.dart on SM J730F in debug mode...
    [  +28 ms] executing: ...\Android\Sdk\platform-tools\adb.exe -s 52009f78e2ae3433 shell -x logcat -v time -s flutter
    [  +13 ms] executing: ...\Android\Sdk\platform-tools\adb.exe version
    [ +158 ms] Android Debug Bridge version 1.0.41
                        Version 29.0.5-5949299
                        Installed as ...\Android\Sdk\platform-tools\adb.exe
    [   +5 ms] executing: ...\Android\Sdk\platform-tools\adb.exe start-server
    [ +120 ms] Building APK
    [  +42 ms] Running Gradle task 'assembleDebug'...
    [   +5 ms] gradle.properties already sets `android.enableR8`
    [  +10 ms] Using gradle from ...\hello_world_flutter\new_hello_flutter\android\gradlew.bat.
    [  +35 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
    [ +784 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java -version
    [   +1 ms] openjdk version "1.8.0_202-release"
               OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
               OpenJDK 64-Bit Server VM (build 25.202-b03, mixed mode)
    [   +8 ms] executing: [...\hello_world_flutter\new_hello_flutter\android\] ...\hello_world_flutter\new_hello_flutter\android\gradlew.bat
    -Pverbose=true -Ptarget=...\hello_world_flutter\new_hello_flutter\lib\main.dart -Ptrack-widget-creation=true -Pfilesystem-scheme=org-dartlang-root
    -Ptarget-platform=android-arm assembleDebug
    [+5300 ms] Starting a Gradle Daemon (subsequent builds will be faster)
    [+33942 ms] > Task :app:compileFlutterBuildDebug
    [   +2 ms] [  +52 ms] executing: [...\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [ +295 ms] [ +277 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [   +1 ms] [   +2 ms] 27321ebbad34b0a3fafe99fac037102196d655ff
    [   +1 ms] [        ] executing: [...\flutter\] git describe --match v*.*.* --first-parent --long --tags
    [ +196 ms] [ +232 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
    [   +1 ms] [        ] v1.12.13+hotfix.5-0-g27321ebba
    [   +1 ms] [  +15 ms] executing: [...\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
    [ +196 ms] [ +228 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
    [   +1 ms] [        ] origin/stable
    [   +1 ms] [        ] executing: [...\flutter\] git ls-remote --get-url origin
    [ +309 ms] [ +214 ms] Exit code 0 from: git ls-remote --get-url origin
    [   +3 ms] [        ] https://github.com/flutter/flutter.git
    [ +285 ms] [ +369 ms] executing: [...\flutter\] git rev-parse --abbrev-ref HEAD
    [ +300 ms] [ +238 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [   +1 ms] [        ] stable
    [   +1 ms] [  +47 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [   +2 ms] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [   +1 ms] [   +9 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [   +1 ms] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [ +181 ms] [ +187 ms] Initializing file store
    [ +100 ms] [  +61 ms] Done initializing file store
    [+2999 ms] [+3011 ms] Skipping target: kernel_snapshot
    [ +199 ms] [ +173 ms] debug_android_application: Starting due to {InvalidatedReason.outputMissing}
    [ +799 ms] [ +841 ms] debug_android_application: Complete
    [   +1 ms] [  +35 ms] Persisting file store
    [  +98 ms] [  +26 ms] Done persisting file store
    [   +1 ms] [   +7 ms] build succeeded.
    [   +1 ms] [  +29 ms] "flutter assemble" took 4 670ms.
    [ +315 ms] > Task :app:packLibsflutterBuildDebug UP-TO-DATE
    [   +3 ms] > Task :app:preBuild UP-TO-DATE
    [   +3 ms] > Task :app:preDebugBuild UP-TO-DATE
    [  +74 ms] > Task :app:checkDebugManifest UP-TO-DATE
    [ +124 ms] > Task :app:generateDebugBuildConfig UP-TO-DATE
    [   +3 ms] > Task :app:compileDebugAidl NO-SOURCE
    [   +1 ms] > Task :app:compileDebugRenderscript NO-SOURCE
    [ +170 ms] > Task :app:cleanMergeDebugAssets
    [   +2 ms] > Task :app:mergeDebugShaders UP-TO-DATE
    [  +96 ms] > Task :app:compileDebugShaders UP-TO-DATE
    [   +1 ms] > Task :app:generateDebugAssets UP-TO-DATE
    [  +98 ms] > Task :app:mergeDebugAssets
    [ +628 ms] > Task :app:copyFlutterAssetsDebug
    [  +15 ms] > Task :app:mainApkListPersistenceDebug UP-TO-DATE
    [   +1 ms] > Task :app:generateDebugResValues UP-TO-DATE
    [   +1 ms] > Task :app:generateDebugResources UP-TO-DATE
    [+4174 ms] > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
    [ +208 ms] > Task :app:processDebugManifest UP-TO-DATE
    [ +369 ms] > Task :app:mergeDebugResources FAILED
    [ +103 ms] FAILURE: Build failed with an exception.
    [   +9 ms] * What went wrong:
    [   +2 ms] Execution failed for task ':app:mergeDebugResources'.
    [   +2 ms] > Multiple task action failures occurred:
    [   +2 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [   +2 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #1: Daemon startup failed
    [   +1 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [   +2 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [   +1 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #4: Daemon startup failed
    [   +2 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [   +3 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [   +2 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #3: Daemon startup failed
    [   +4 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [   +2 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [   +8 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #5: Daemon startup failed
    [  +21 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [  +18 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [  +33 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #6: Daemon startup failed
    [  +10 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [   +2 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [   +2 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #0: Daemon startup failed
    [  +17 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [  +12 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [  +28 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #2: Daemon startup failed
    [   +4 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [   +4 ms]    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    [  +20 ms]       > AAPT2 aapt2-3.5.2-5435860-windows Daemon #7: Daemon startup failed
    [   +4 ms]         This should not happen under normal circumstances, please file an issue if it does.
    [   +3 ms] * Try:
    [   +3 ms] 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.
    [   +8 ms] * Get more help at https://help.gradle.org
    [   +8 ms] BUILD FAILED in 51s
    [   +1 ms] 14 actionable tasks: 5 executed, 9 up-to-date
    [ +616 ms] Running Gradle task 'assembleDebug'... (completed in 53,3s)
    [  +15 ms] "flutter run" took 55 781ms.
    Gradle task assembleDebug failed with exit code 1
    

    EDIT 2: I've installed VC redist (newest 2019) for x64 and ARM. After reboot error still appear: https://pastebin.com/2Jiea3wq

    EDIT 3: After reboot without fast start I've done flutter clean and flutter build apk -v and same error appear but I see this (line 87 in pastebin):

    invalidated build due to missing files: .\flutter\bin\cache\artifacts\engine\android-arm-release\windows-x64\gen_snapshot
    

    Is it a problem? Complete log: https://pastebin.com/vYvLzStv

    • Yudhishthir Singh
      Yudhishthir Singh over 4 years
      try flutter clean to delete the current build and let it make a new one when you run it again...
    • Wiszen
      Wiszen over 4 years
      @YudhishthirSingh I've clean it and run - same error happen
    • Yudhishthir Singh
      Yudhishthir Singh over 4 years
      try to run with --stacktrace and add to the question , it will give us a better insight.
    • Izabela Orlowska
      Izabela Orlowska over 4 years
      Do you have windows universal c runtime library installed?
    • Wiszen
      Wiszen over 4 years
      @YudhishthirSingh stacktrace option is not possible with flutter run. I've added stacktrace from gradle
    • Wiszen
      Wiszen over 4 years
      @IzabelaOrlowska Universal C runtime is for older system than windows 10? My system is Win10.
  • Wiszen
    Wiszen over 4 years
    I've installed VC redist for x64 and ARM. I had prevoiusly installed x86. Still error occurs. See verbose: pastebin.com/2Jiea3wq
  • Wiszen
    Wiszen over 4 years
    I have VC 2013 and VC 2019. Is this a problem?
  • Wiszen
    Wiszen over 4 years
    Which path exactly set as GRADLE_USER_HOME? gradle comes with flutter and I don't manually start it.
  • Martin Zeitler
    Martin Zeitler over 4 years
    @Wiszen you've accepted the wrong one answer, because with GRADLE_USER_HOME you can set any path you like, in order to circumvent possible policy or permission restrictions. And if, then Flutter comes with Gradle and there is nothing which would prevent running it, just cd to the Android project.
  • Izabela Orlowska
    Izabela Orlowska over 4 years
    Not sure. All I know is that this error happens when you're missing the windows universal C runtime librar.
  • Huy Tower
    Huy Tower almost 4 years
    Yes, if using Mac, run sudo flutter run -v to upgrade Gradle version.