示例Hello world flutter应用程序构建失败:任务':app:mergeDebugResources'的执行失败

时间:2020-01-05 19:59:11

标签: android windows flutter

我最近安装了flutter,并尝试运行由example app(编辑器flutter)创建的VSCode,但出现以下错误(也{{ 1}}命令失败):

build

代码未更改(lib / main.dart):

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

./ android / build.gradle:

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 / app / 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 / gradle.properties:

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'
}

扑打医生:

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

Gradle堆栈跟踪:

[√] 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!

编辑: 我已经使用详细选项运行了命令:

#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)

编辑2:我已经为x64和ARM安装了VC redist(最新的2019年)。重新启动后,错误仍然出现:https://pastebin.com/2Jiea3wq

编辑3:在没有fast start的情况下重启后,我完成了$ 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 flutter clean的操作,虽然出现了相同的错误,但我看到了(pastebin中的第87行) :

flutter build apk -v

有问题吗?完整的日志:https://pastebin.com/vYvLzStv

3 个答案:

答案 0 :(得分:2)

android-arm64-release用于发行版本,而mergeDebugResources是调试版本的任务。如果有任何有趣的日志,那将是(这可能与其他日志一样,当它不能启动AAPT2时就不讲故事了):

gradlew.bat --stacktrace assembleDebug
  • 如果AAPT2因任务mergeDebugResources而失败,则可能是资源有问题。

  • 如果AAPT2无法启动,则可能是UCRT ...,但是aapt2是JAR。

  • 在Windows上将GRADLE_USER_HOME设置为环境变量。

即使对于某些“ hello world”程序来说选项#1不太可能...我还是建议尝试构建一个常规的Android项目...只是为了摆脱所有Flutter的复杂性,以查看AAPT2是否甚至开始。

答案 1 :(得分:1)

通常,这意味着您缺少Windows通用C运行时库。但是,由于您说过您正在使用Windows 10,因此由于某些原因,您的系统似乎缺少了C运行时库,即使它已经安装(或在更新中)也是如此。 您可以通过从here安装适用于Visual Studio的Microsoft Visual C ++ Redistributable(当前版本为2019)来获得此缺少的库。

答案 2 :(得分:1)

最后,我知道导致问题的原因:在git show MERGE_HEADProgram Files等其他地方运行程序受到限制。在Program Data示例项目和{{ 1}}我看到了错误消息:

Android Studio

我已经在管理控制台中运行了flutter run -v,并且运行正常。我认为this program is blocked by group policy. for more information contact your system administrator 尝试下载并在flutter run -v中运行某事-有人知道如何解决此问题吗?