Gradle构建无法生成.apk文件

时间:2019-12-22 07:59:46

标签: flutter

将Flutter从1.9.7升级到v1.12.13 + hotfix.5后,我的应用程序构建失败。我遇到以下异常:

[ +124 ms] > Task :draw:compileFossDebugSources UP-TO-DATE
[   +5 ms] > Task :draw:assembleFossDebug UP-TO-DATE
[ +136 ms] Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
[        ] Use '--warning-mode all' to show the individual deprecation warnings.
[        ] See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
[        ] BUILD SUCCESSFUL in 5m 30s
[        ] 396 actionable tasks: 16 executed, 380 up-to-date
[ +529 ms] Running Gradle task 'assembleFossDebug'... (completed in 331.1s, longer than expected)
[  +35 ms] "flutter run" took 332,133ms.
Gradle build failed to produce an .apk file. It's likely that this file was generated under C:\flutter_projects\my_branch\iamflexi_app\build, but the tool couldn't find it.

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

但是,当我在Android Studio中的Android模块中打开我的应用程序时,它运行正常,但是当我尝试与Flutter一起运行时,出现了此错误。

1 个答案:

答案 0 :(得分:0)

使用 Android Studio 可能会提示您升级项目的设置(即 gradle 版本)。对此问题的快速解决方法是降级到之前在评论中提到的项目的先前 gradle 版本。您还可以尝试查看在此 GitHub 问题线程 ahttps://github.com/flutter/flutter/issues/45681 上发布的建议,看看是否有任何适合您的方法。