flutter build apk-当flutter build apk发行失败-调试正常

时间:2019-05-10 22:38:45

标签: flutter

我需要为我的flutter项目释放一个签名的apk,但是“ flutter build apk --release”命令失败。

“ flutter build apk --debug”命令运行正常。 我已经使用“ Flutter Doctor”检查了设置,一切似乎都很好。 我曾尝试用飘动的清洁来清洁项目,但这没有帮助。

“ flutter build apk --debug -v”返回的错误是:

Gradle build failed to produce an Android package.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:24:3)
#1      _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:484:7)
<asynchronous suspension>
#2      buildGradleProject (package:flutter_tools/src/android/gradle.dart:346:14)
<asynchronous suspension>
#3      buildApk (package:flutter_tools/src/android/apk.dart:34:9)
<asynchronous suspension>
#4      BuildApkCommand.runCommand (package:flutter_tools/src/commands/build_apk.dart:51:11)
<asynchronous suspension>
#5      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:559:18)
#6      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_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-patch/async_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-patch/isolate_patch.dart:115:13)
#21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:5)

3 个答案:

答案 0 :(得分:1)

根据Android SDK文档,您可以根据sdkmanager的位置使用以下命令:--licenses选项上的文档似乎丢失了。

yes | sdkmanager --licenses

GNU / Linux发行版:

yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses

macOS

导出JAVA_HOME = / Applications / Android \

Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses

Windows:

%ANDROID_HOME%/tools/bin/sdkmanager --licenses

同时运行Flutter Clean

答案 1 :(得分:0)

如果您正确地跟踪了Signing the app的此链接(如果您想将其上传到游戏商店),那么以下命令应该可以正常工作:

flutter build apk --release

如果上述方法不起作用,请尝试使用:

flutter build apk  // this command default creates the release apk, but don't know if you can upload it to play store 

答案 2 :(得分:0)

错误是由于密钥库的密码无效所致。修复后,编译正确。