如何修复“ Gradle build未能产生Android捆绑包”。在Flutter [英] How to fix "Gradle build failed to produce an Android bundle package." in Flutter

查看:417
本文介绍了如何修复“ Gradle build未能产生Android捆绑包”。在Flutter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行
flutter build appbundle 时,出现以下错误:
Gradle build无法生成Android捆绑包。

On running flutter build appbundle I am getting the following error: Gradle build failed to produce an Android bundle package.

在详细模式下运行时,这也是我所得到的:

When running in verbose mode this is what I additionally get:

#0      throwToolExit (package:flutter_tools/src/base/common.dart:24:3)
#1      _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:585:7)
<asynchronous suspension>
#2      buildGradleProject (package:flutter_tools/src/android/gradle.dart:331:14)
<asynchronous suspension>
#3      buildAppBundle (package:flutter_tools/src/android/app_bundle.dart:43:10)
<asynchronous suspension>
#4      BuildAppBundleCommand.runCommand (package:flutter_tools/src/commands/build_appbundle.dart:43:11)
<asynchronous suspension>
#5      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:545:18)
#6      _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
#7      _rootRunUnary (dart:async/zone.dart:1132:38)
#8      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#9      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#10     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#11     Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#12     Future._complete (dart:async/future_impl.dart:473:7)
#13     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#14     _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
#15     _rootRun (dart:async/zone.dart:1124:13)
#16     _CustomZone.run (dart:async/zone.dart:1021:19)
#17     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#18     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#20     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#21     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

我在Flutter稳定频道v1.2.1上。

I am on Flutter stable channel v1.2.1.

我可以毫无问题地构建apk。
我也可以从另一个Flutter项目中构建一个appbundle。

I can build an apk without a problem though. I can also build an appbundle from another Flutter project.

根据上述错误消息,您将如何开始发现问题?
这里可能是什么问题?

Based on the error messages above how would you start to find the issue? What might be the problem here?

推荐答案

我有类似的问题,但有相同的错误消息。
(成功构建APK,但无法构建应用捆绑包)
对我有效的解决方案是升级Android Gradle版本。
以下是适用于我的配置(您也可以升级到最新版本):

I have similar issue with the same error messages. (Build Release APK successfully but failed to build app bundle) The solution that works for me is to upgrade the Android Gradle Version. Below are the config that works for me (You may upgrade to the latest version also):


  1. / android /gradle/wrapper/gradle-wrapper.properties

  1. /android/gradle/wrapper/gradle-wrapper.properties:

distributionUrl = https\: //services.gradle.org/distributions/gradle-4.10.2-all.zip


  1. /android/build.gradle

buildscript {
    repositories {
       google()
       jcenter()
      }

    dependencies {
       classpath 'com.android.tools.build:gradle:3.2.1'
    }
}


这篇关于如何修复“ Gradle build未能产生Android捆绑包”。在Flutter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆